Should "const" be favored over "let"?

Allen Wirfs-Brock allen at
Fri Apr 17 16:16:46 UTC 2015

On Apr 17, 2015, at 5:09 AM, Alex Kocharin wrote:

> There won't be any performance gain. "const" is used to be much slower in v8 actually. But they fixed it as far as I know.
> I think it's a code style matter. And speaking about that, realistically, most code base will never use "const" widely. Just one reason: 5 characters vs 3 characters to type. So in the name of keeping an amount of different code styles smaller, I'd say stick with "let" (except for obvious constant literals like `const PI = 3.14` on top). Just something to consider.

I agree, 'let' is likely to win because of it's length.  I find that I fall into using it solely or that reason.  I think it also wins on readability. 

If we had a "do-over".  I'd make `let` means what `const` now means and have something different for defining mutable lexical bindings.  Maybe `let var foo=...;`.

But the let/const pairing was a firmly established direction long before work on ES6 even started.  There was so much other stuff to work on and so much inertia behind let/const that nobody ever seriously challenged that direction. 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list