If there is a constructor like
function a() {}
then
(new a) instanceof a === true
But on the other
According to the spec: If calling the constructor returns an object, then this object is the result of the new
-expression. If the constructor doesn't return an object (but undefined
or some other primitive value), the result is the newly created object.
If primitives were allowed, then all constructors would have to explicitly return something (typically "this
"), otherwise the result would be undefined
(because the result of a function without a return
is undefined
). That would be a needless hassle.
Additionally, it makes sense that new
can be relied on to always return an object.