Supporting feature tests directly

Kyle Simpson getify at
Sun Mar 22 01:00:53 UTC 2015

> I think you're referring to the `eval` function?

Actually, I'm referring to proposing something new that would substitute for having to hack feature tests with `eval`.

These are the initial details of my idea, a `Reflect.supports(..)` method:

Summary: `Reflect.supports( "(()=>{})" )` or `Reflect.supports( "let x" )` could test **just** for the ability to parse, as opposed to the compilation/execution that `eval(..)` does. It'd be much closer to `new Function(..)` except without the overhead of needing to actually produce the function object (and then have it be thrown away for GC).

This is inspired by, where FF has a `Reflect.parse(..)` method that is somewhat like what I'm suggesting, except that for feature tests we don't need the parse tree, just a true/false of if it succeeded.

An alternate form would be `Reflect.supports( Symbol.arrowFunction )`, where the engine is just specifically saying "yes" I support that feature by recognizing it by its unique built-in symbol name.

More information about the es-discuss mailing list