T.J. Crowder (2017-01-16T17:24:37.000Z)
Related: There's [a proposal][1] for `Reflect.isConstructor` (and
`Reflect.isCallable`) which addresses this very gap. There seem to be some
questions around `Reflect.isCallable` (whether it should be true or false
for class constructors, since you can't [[Call]] them), but I didn't see
issues raised around `Reflect.isConstructor`. Seems a bit stalled, though.

[1]
https://github.com/caitp/TC39-Proposals/blob/master/tc39-reflect-isconstructor-iscallable.md

-- T.J.


On Mon, Jan 16, 2017 at 5:00 PM, Michael Haufe <tno at thenewobjective.com>
wrote:

> The question came up recently on CLJS [1] on how to determine if an object
> is safe to call as a Constructor.
>
> Traditionally one uses try {... x = new foo() ... } catch(e) { ... x =
> foo() }
>
>
> In the list of well-known symbols [2] there doesn't seem to be a way to
> reference [[Construct]] to perform a test to avoid the try/catch.  In the
> following[3] though there is reference to Symbol.create which doesn't seem
> to be in the spec but seems to be the one to look for. Can we get
> clarification on if it is possible to determine if an object can be
> constructed before attempting it?
>
> [1] <https://groups.google.com/forum/#!msg/comp.lang.
> javascript/nSesJfznwjg/rKiQOzkYEwAJ>
> [2] <http://www.ecma-international.org/ecma-262/7.
> 0/#sec-well-known-symbols>
> [3] <https://github.com/lukehoban/es6features/blob/master/
> README.md#subclassable-built-ins>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170116/4c3b1e4e/attachment.html>
forbes at lindesay.co.uk (2017-01-18T10:37:58.007Z)
Related: There's [a proposal](https://github.com/caitp/TC39-Proposals/blob/master/tc39-reflect-isconstructor-iscallable.md) for `Reflect.isConstructor` (and
`Reflect.isCallable`) which addresses this very gap. There seem to be some
questions around `Reflect.isCallable` (whether it should be true or false
for class constructors, since you can't [[Call]] them), but I didn't see
issues raised around `Reflect.isConstructor`. Seems a bit stalled, though.