Determining if an object can be constructed

Michael Haufe tno at
Mon Jan 16 17:00:40 UTC 2017

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] <!msg/comp.lang.javascript/nSesJfznwjg/rKiQOzkYEwAJ
[2] <>
[3] <
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list