3 ms·
'const' in JS is 100% for readability and enables no additional optimizations above 'let'. In fact 'const' and 'let' are often worse than 'var' because of the t
by millstone 7y ago
'const' in JS is 100% for readability and enables no additional optimizations above 'let'. In fact 'const' and 'let' are often worse than 'var' because of the temporal dead zone.
- hombre_fatal 7y ago> In fact 'const' and 'let' are often worse than 'var' because of the temporal dead zone. Seems like a massive overstatement. What are you even referring to as the downside? For 99% of usecases/people, TDZ just means you get a runtime error for your use-before-declaration bugs. The only reason I can see for using `var` is if you're doing some very confident performance hacking in a hot loop and you have the performance testing harness to prove that you're not just wasting your time.