4 ms·
There was another thing that CoffeeScript provides that I still missed a couple of years ago when moving to ES6/7 only projects. While ES6 provided a lot of con
by xiaoma 10y ago
There was another thing that CoffeeScript provides that I still missed a couple of years ago when moving to ES6/7 only projects. While ES6 provided a lot of conveniences from CS, like destructured params and a terser function syntax, it couldn't remove anything.
I've never intentionally used JS == comparisons in any code I've written for work, but I've still had to deal with code written by others that did. CoffeeScript eliminates the possibility entirely by only having a == operator, and it works like a JS ===. Similarly, CS won't let you leak a var to global scope by forgetting to declare. Every variable is local by default and if you don't want that, you've got to explicitly set window.someVar.
In short, compile to JS languages have the advantage of being able to eliminate foot guns rather than just tack on new features. ES2018 probably isn't going to get rid of any. Even extremely dangerous and mostly unused keywords like with will remain because of backwards compatibility concerns.
- Hurtak 10y ago'use strict' solves the forgotten 'var' and dangerous 'with' by prohibiting these parts of language. Also if you are using ES2016+ you are most likely compiling your code with Babel (to have more backwards compatibility) it will turn on the strict mode on by default.
- xiaoma 10y ago"use strict" will save you from some of the foot guns but not all of them. E.g. it still allows the double equal comparisons I mentioned above, which have been the source of some frustrating debugging sessions ever. If you want a safe language on the front end, use Elm.