>
> Extend builtins, in particular - ie, `super()` allows your subclass to
> obtain internal slots it can't otherwise get.
>
> Even if `class` were just sugar, I don't think I see the argument that
> that's a *good* thing to preserve.
>
`Reflect.construct` allows subclasses to obtain internal slots without
`super()` / class syntax.
```js
const SubDate = function (...args) {
const instance = Reflect.construct(Date, args, SubDate);
return instance;
};
Object.setPrototypeOf(SubDate.prototype, Date.prototype);
const sub = new SubDate();
sub.getDate(); // has internal slots, does not throw
sub instanceof SubDate; // true
sub instanceof Date; // true
```
This is the first I have heard `class` is anything but sugar.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss