4 ms·
I don't think I'd call any of those reasons good; the main thrust of them is "const doesn't do everything, so don't let it do anything". If that line of reason
by elyobo 7y ago
I don't think I'd call any of those reasons good; the main thrust of them is "const doesn't do everything, so don't let it do anything". If that line of reasoning is appealing, then one might as well continue using var.
- megous 7y agoThe main benefit of let/const over var is that it's block scoped. The benefit of const over let is pretty much nothing, much. It only prevents some limited form of re-binding. You can still easily re-bind const variables from inside a function: const x = 1; (function() { const x = 2; console.log(x); })() or from an argument: const x = 1; (function(x) { console.log(x); })(2) So it has limited value in any code that uses closures.