3 ms·
I don't think I agree with your point. Javascript is a very small language, and while there are a number of gotchas they are enumerable and well-defined. Centr
by ender7 13y ago
I don't think I agree with your point. Javascript is a very small language, and while there are a number of gotchas they are enumerable and well-defined.
Central concepts:
- Objects
- Prototypes
- Scope chains
- Closures
- Function.bind, Function.apply/Function.call
Gotchas:
- Behavior of the "new" operator
- Value of "this"
- Type coercion, falsiness of "", == vs. ===
- var hoisting
- if/for/while do not create scope
- function expression vs. function declaration
Many of the gotchas are self-evident if you learn the central concepts.
- crazygringo 13y agoExactly. I can deal with "gotchas" and edge cases as long as they're documented and I can memorize them -- which is 100% the case with JavaScript. The reason I'll never use CoffeeScript again isn't because of its gotchas -- it's because there's no way to learn them. They're not documented. They're not predictable from principles. They're completely hidden.
- michaelwww 13y agoIt sounds like CoffeeScript violates the principle of least surprise [1] for you (and me too.) On the other hand, when I use a language like C# (whose author is also behind TypeScript) I often find myself thinking "it should work this way" and then finding out is does work that way. [1] https://en.wikipedia.org/wiki/Principle_of_least_astonishment https://en.wikipedia.org/wiki/Principle_of_least_astonishmen...