4 ms·
#4 pretty much the only advantage of CoffeeScript is saving a few keystrokes, not worth spending time on Well, I suppose you could also say that the reason I m
by mratzloff 14y ago
#4 pretty much the only advantage of CoffeeScript is saving a few keystrokes, not worth spending time on
Well, I suppose you could also say that the reason I might use Ruby over Java is to "save a few keystrokes". I'm exaggerating to make the point that shortcuts for common tasks are important.
- String interpolation (`"foo#{bar}baz"`)
- Existence unary operator (`foo?`, `foo ? "bar"`)
- Splats (`(foo, bar...) ->`)
- Comparison chaining (`10 < foo < 20`)
- Loops and comprehensions (`x() for x in ["foo", "bar"]`)
- Destructuring (`[foo, bar] = items`)
- Ranges (`num for num in [1..10]`)
- Array slicing (`items[3..5]`)
- Object properties (`for own key, value of object`)
I think these are all substantive improvements to JavaScript, not even taking into account readability-improving sugar like post-conditions.