4 ms·
It's part of type enforcement for me (note: I do my work in typescript); if you never intend to redefine it, make it a const, then you'll get an error if you tr
by chadlavi 7y ago
It's part of type enforcement for me (note: I do my work in typescript); if you never intend to redefine it, make it a const, then you'll get an error if you try to redefine it later.
performance-wise, const is also around 20% faster than var, and usually faster than let (you can test it yourself: https://jsperf.com/let-vs-var-performance/67 https://jsperf.com/let-vs-var-performance/67).
Edit: I forgot (because I always just write `const` anyway), but TSLint/VScode also default to bothering you to use const if you define a let/var and never re-define it.