Determining if an object can be constructed

Claude Pache claude.pache at gmail.com
Thu Jan 19 07:50:06 UTC 2017


> Le 17 janv. 2017 à 23:56, Oriol _ <oriol-bugzilla at hotmail.com> a écrit :
> 
> See my http://stackoverflow.com/questions/39334278/check-if-object-is-a-constructor-isconstructor <http://stackoverflow.com/questions/39334278/check-if-object-is-a-constructor-isconstructor>
> 
> I also thought the `extends` trick could be useful, but it fails 3 of my tests. It doesn't work for bounded normal functions and some proxy objects.

Yes, I missed the fact that subclassing implies a concrete access to the `prototype` property of the superclass in order to construct the subclass' prototype. That is the root of the failures.

> 
> The proper way is the second one in Claude's post: using a proxy object.
> 
> There is only a problem: it doesn't work for revoked proxies, because they can't be used as a proxy target.
> 
> In my opinion that restriction is somewhat stupid, because you can use a revocable proxy as a proxy target, and revoke it later.
> 
> But I guess it's too late to change that.

It is not too late to change that point, in that the risk of breakage may reasonably be judged almost inexistant. The hard part is to convince people that the inability to use a revoked proxy as proxy target is troublesome enough in order to justify the change. (Also, knowing why there is such a restriction may help to judge.)


> Maybe some day we will have `Object.isConstructor`.
> 
> ;Oriol
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
> https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170119/5f95dd01/attachment-0001.html>


More information about the es-discuss mailing list