3 ms·
> JavaScript still only has prototypal inheritance; class syntax is just sugar[1]. Sure, but the patterns you use with the class syntax are incompatible with t
by kerkeslager 10y ago
> JavaScript still only has prototypal inheritance; class syntax is just sugar[1].
Sure, but the patterns you use with the class syntax are incompatible with the patterns you use when using object literals, so libraries pick one or the other, typically the class way.
> Even with arrow functions, which don't change the binding of "this"[2]?
Even with arrow functions, `function` still exists ands is more frequently used.
> Trying to access a nonexistent variable throws a ReferenceError[3].
var a = {};
var b = a.c;
Doesn't throw a ReferenceError for me.
- jakelazaroff 10y ago> Sure, but the patterns you use with the class syntax are incompatible with the patterns you use when using object literals How so? You can still access the prototype. It's just that the most common reason to — declaring instance methods — can be accomplished with the easier-to-read class syntax now. > Even with arrow functions, `function` still exists ands is more frequently used. ES6 is a non-breaking change. You can use arrow functions for literally every function you write other than generators. > var a = {}; > var b = a.c; That's a nonexistent property, which probably should throw some sort of error — but that's why we have tools like TypeScript and Flow that can detect this.
- fauigerzigerk 10y ago>You can use arrow functions for literally every function you write other than generators But not for every function I read, and that is the problem with all backward compatible fixes to programming languages. You're just piling on more (sometimes better) features on top of all the old brokenness and everybody has to know all of it.
- ng12 10y agoYeah but that's in no way unique to Javascript. Java developers still have to deal with type erasure due to decisions that were made 20 years ago.
- jakelazaroff 10y agoTrue. I'm not trying to say JavaScript is or was great, just that ES6 is pretty clearly not a step backward (which was the original claim).