Should "const" be favored over "let"?

Glen Huang curvedmark at
Fri Apr 17 12:35:10 UTC 2015


Thanks for the clarification. I should use "never rebind".

@Alex @Frankie

You guys are right. There won't be any performance gain since it's already statically analyzable.

FWIW, I opened a feature request on eslint concerning this coding style: <> 

> On Apr 17, 2015, at 8:17 PM, Mathias Bynens <mathiasb at> wrote:
> On Fri, Apr 17, 2015 at 7:53 AM, Glen Huang <curvedmark at> wrote:
>> I've completely replaced "var" with "let" in my es 2015 code, but I noticed most variables I introduced never change.
> Note that `const` has nothing to do with the value of a variable
> changing or not. It can still change:
>    const foo = {};
> = 42; // does not throw
> `const` indicates the *binding* is constant, i.e. there will be no
> reassignments etc.
> In my post-ES6 code, I use `const` by default, falling back to `let`
> if I explicitly need rebinding. `var` is for legacy code.

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

More information about the es-discuss mailing list