Should "const" be favored over "let"?

Andreas Rossberg rossberg at
Fri Apr 17 13:20:27 UTC 2015

On 17 April 2015 at 14:17, 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.

I have to nitpick on this. In usual nomenclature of programming language
semantics the "value" in question is the _reference_ to the object (for
types with reference semantics), and that does not change. That the object
itself actually can be mutable is a separate property.

The idea that const somehow applies transitively is a specific idiosyncrasy
of low-level languages like C and friends, that make flattening and copying
of mutable objects an implicit part of their semantics. It is not the norm,
and actually rather contorted semantically.


> In my post-ES6 code, I use `const` by default, falling back to `let`
> if I explicitly need rebinding. `var` is for legacy code.
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list