Subclassing ES6 objects with ES5 syntax.

Kevin Smith zenparsing at gmail.com
Tue Apr 28 03:01:25 UTC 2015


>
> x = Reflect.construct(Promise, x, C);
>
> is another fine way to fool someone who wrote "C.resolve(x)" and expected
> to get an instance of C back.
>

Thanks for pointing this out.  I believe the ability to use an arbitrary
newTarget parameter for Reflect.construct is breaking the intent of
Promise.resolve.  Using an arbitrary "newTarget" is also problematic for
the private fields proposal.

It seems to me that Reflect.construct has been given a capability that is
not otherwise expressible with ES6 syntax, and that gap is problematic.

Maybe I've missed some context though.  Mark, Allen, any thoughts?

Looking over the Reflect namespace, I also see that Reflect.get and
Reflect.set have been given powers not expressible with syntax:  the
receiver does not have to be a prototype parent of the target.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150428/d5e7f415/attachment.html>


More information about the es-discuss mailing list