@Mathias 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: https://github.com/eslint/eslint/issues/2333 <https://github.com/eslint/eslint/issues/2333> > On Apr 17, 2015, at 8:17 PM, Mathias Bynens <[email protected]> wrote: > > On Fri, Apr 17, 2015 at 7:53 AM, Glen Huang <[email protected]> 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 = {}; > foo.bar = 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.
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

