proposal: Object Members
Michael Theriot
michael.lee.theriot at gmail.com
Tue Jul 24 07:00:05 UTC 2018
>
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180724/45d5e7e7/attachment.html>
More information about the es-discuss
mailing list