lukehoban / es6features

Overview of ECMAScript 6 features
MIT License
29.2k stars 2.87k forks source link

More emphasis on `const` gotchas? #90

Open chakrit opened 9 years ago

chakrit commented 9 years ago
const x = { 'hello': 'world' };
x['hello'] = 'alien';
console.log(x['hello']); // prints 'alien'
x = { }                  // fails silently.
console.log(x['hello']); // still prints 'alien'

This (correctly) prints 'alien' but may not be apparent to many people. I think this should be at least noted in the example.

getify commented 9 years ago

// fails silently.

that won't be true of a conforming implementation. it'll throw an error affirmatively.