Yes and no. Although we get some fantastic features, one of the most critical- the ability to neglect parens and curly braces- is lost in es6. I'm working on an es6 project right now and still prefer coffeescript.
Replace CoffeeScript with ES6
11–20 of 178 posts
Re: Replace CoffeeScript with ES6
#12ES5 has Function.bind
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Re: Replace CoffeeScript with ES6
#13Note that self = this is kind of a legacy hack for binding 'this'. ES5 has Function.bind https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Re: Replace CoffeeScript with ES6
#14I give credit to CoffeeScript with really helping to push the ES specs forward and think it helped introduce more people to JS and grow the ecosystem. Heck, I used it for a year, liked it, and had it change some of my approaches to writing JS. That said, I hope it slowly fades into the background as more people go back to vanilla ES6 or go with something more powerful such as TypeScript (or Flux). With the progress a…
That being said, you're absolutely right, folks who write in Coffee should also absolutely eventually learn all the tips and tricks behind vanilla js also if they don't want to be bogged down.
Re: Replace CoffeeScript with ES6
#15Re: Replace CoffeeScript with ES6
#16You can start using transforms that provide features other than ES6: https://6to5.org/docs/usage/transformers/
Re: Replace CoffeeScript with ES6
#17Re: Replace CoffeeScript with ES6
#18Re: Replace CoffeeScript with ES6
#19Why not both? This makes a good argument for ES6, but CoffeeScript's fundamental changes to syntax are just preferred by some.
Because one day ES6 will run in browsers without a build step.
This isn't an issue for node projects as you can simply `require` the `coffee-script/register` module and node handles coffee scripts for you via normal `requires`.
Re: Replace CoffeeScript with ES6
#20Note that self = this is kind of a legacy hack for binding 'this'. ES5 has Function.bind https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
var Person = function(name) {
var self = this;
self.name = name
};
Person.prototype = new function() {
var prototype = this;
prototype.sayHello = function() {
var self = this;
return "Hello\n\n-- " + self.name;
};
};
var me = new Person('Peter');
console.log(me.sayHello());
Obviously that's a pretty contrived example but it illustrates the idea. It makes it really clear exactly what "this" means at different points in your code. As a bonus, if I had to reference the current context inside of a prototype method, "this" is now available.