Should "const" be favored over "let"?

Mathias Bynens mathiasb at
Fri Apr 17 12:17:10 UTC 2015

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.

More information about the es-discuss mailing list