4 ms·
How much Javascript have you written? This has dynamic closure. Everything else has lexical closure. Vars can be declared inside a block but it has no effect,
by tomjen3 15y ago
How much Javascript have you written?
This has dynamic closure. Everything else has lexical closure.
Vars can be declared inside a block but it has no effect, because they are always scoped to the nearest function.
Variables must be declared with var, or they will still work but they will be scoped to the global environment.
Equality isn't transitive.
NaN is not NaN.
The way to convert a number to a string? Append a string.
aString + aNumber = aString
aString - aNumber = NaN
etc.
- anonymoushn 15y agoNaN !== NaN is not a JavaScript thing so much as a floating point thing. === is transitive as far as I know, and you should have a pre-commit hook that prevents anyone from ever using ==.
- ams6110 15y agoThere are probably as many if not more idiosyncrasies with any programming language.
- quink 15y agoBingo. And it doesn't need anything as heavy as Dart to provide some nicely syntactical and automated sugar. CoffeeScript is quite enough and maps one-to-one with the generated JavaScript. It would be nice to have Python-style operator overloading in JavaScript, but I don't care that much, since it probably helps make JavaScript faster, for varying definitions of faster.
- twerquie 15y ago> The way to convert a number to a string? Append a string. You can always call intVar.toString() if it pleases.