ECMAScript-regrets
ECMAScript-regrets copied to clipboard
Learning from mistakes of the past
`!'property' in object` is interpreted as `(!'property') in object` (=> `false in object`) which is [not what people want](https://bugzilla.mozilla.org/show_bug.cgi?id=859707#c4) the vast majority of the time. Where writing this, people want...
``` js re = /foo/g; alert(re.test('now foo')); alert(re.test('foo now')); This will alert first true then false #wtfjs ``` https://twitter.com/erikcorry/status/231050692553502720 https://twitter.com/BrendanEich/status/231066800304046080
==
Arguably useless and creates more confusion than anything else.
- global functions - too tolerant (should be part of a library)
Forked out of #25. JavaScript has both `undefined` and `null` while only one could be enough.
Certain specified behaviours of native constructors can't be simulated, such as setting the `[[Class]]` and `[[PrimitiveValue]]` properties. This prevents us from constructing an instance of these constructors with a nondeterministic...
Some names (like `undefined` and `NaN`) can be used as identifiers making it hard to use them 100% reliably as values (which is what people expect naturally). This leads people...
De-facto standard. Shouldn't be in the language in the first place.
2 independent scripts need to communicate through some symbols, but the global object was a step too far. in ES6 let/const/import/class are staying away from the global object.
`+` can mean either addition or string concatenation depending on its operands. And if neither operand is a literal (`a + b`), it becomes a chore to figure out which...