Reflect.type

Alexander Jones alex at weej.com
Thu May 14 16:29:53 UTC 2015


Just an idea, if it doesn't already exist somewhere.

Reflect.type(x) would match the spec's Type(x) function, in that it would
basically be a better, more convenient typeof, i.e.

    Reflect.types = {
        undefined: Symbol(),
        null: Symbol(),
        boolean: Symbol(),
        string: Symbol(),
        symbol: Symbol(),
        number: Symbol(),
        object: Symbol(),
    }

    Reflect.type(null) === Reflect.types.null
    Reflect.type(function() {}) === Reflect.types.object

We weren't able to fix typeof null in harmony, but this seems like a good
opportunity to introduce something new. Haven't thought about the
repercussions of future support for new value types...

Any thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/d302b457/attachment-0001.html>


More information about the es-discuss mailing list