! Hola, amigos. I have this little class inheritance structure
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
toStri
super(…);
is basically sugar for this = new ParentConstructor(…);
. Where ParentConstructor
is the extended class, and this =
is the initialisation of the this
keyword (well, given that that's forbidden syntax, there's a bit more than sugar to it). And actually it will inherit from the proper new.target.prototype instead of ParentConstructor.prototype
like it would from new
. So no, how it works under the hood does not compare to ES5 at all, this is really a new feature in ES6 classes (and finally enables us to properly subclass builtins).