Add Reflect.isConstructor and Reflect.isCallable?

Jason Orendorff jason.orendorff at gmail.com
Fri Dec 19 09:22:55 PST 2014


On Tue, Dec 16, 2014 at 3:05 PM, Tom Schuster <tom at schuster.me> wrote:
> Hello,
>
> right now there is no way in normal JS code to replicate the IsConstructor
> check defined in 7.2.4.

function isConstructor(obj) {
    var p = new Proxy(obj, {construct() { return p; }});
    try {
        new p;
    } catch (exc) {
        return false;
    }
    return true;
}

This works by exposing the code in 9.5.15 ProxyCreate that's more or
less equivalent to IsConstructor.

-j


More information about the es-discuss mailing list