While the term “constructor” is defined (as indicated by @RobG), there is nothing that would prevent the non-Constructor object from having [[Construct]]
.
This is a bit confusing. This means that you can use the new
operator on an object that is not Function
(thus, it is not a "constructor" in accordance with 4.3.4 ), but does provide a [[Construct]]
method.
Note that none of the standard objects are suitable for this, but host objects really can. A browser plugin, such as Java, can expose some object:
new java.lang.String(); // it works, so java.lang.String has a [[Construct]] method java.lang.String instanceof Function // false Object.prototype.toString.call(java.lang.String).indexOf('Function') // -1
Note that typeof java.lang.String
returns "function"
, although java.lang.String
not a function. This is true in accordance with 11.4.3 (this is a host object with the [[Call]]
method)
source share