`new Object` vs `Object` difference
benjamingr at gmail.com
Fri Jun 12 20:19:37 UTC 2015
Ok, so I gave this a few hours in the open.
So, I'm looking at the ES5 specification (also checked the current ES draft
which is similar) at the definition of what new Object and Object do. To my
- `new Object` describes a whole algorithm of how the object constructor
works - treating what happens with different kinds of values. Basically
calls `ToObject` on non objects - identity on objects and builds on null
- `Object` has a special first step for null and undefined where it builds
an object and then calls `ToObject` on primitives and identity on objects.
After reading the description a few times - they seem identical. However,
clearly from the spec they do *something* different. For example in Array -
calling new Array is specified as the function call Array(…) is equivalent
to the object creation expression new Array(…) with the same arguments.`
The only difference I've been able to identify with the help of a friend is
that the behaviour can be different on host objects. Where `Object` must
return the same host object and `new Object` _may_ return the same host
I've taken a look at the ES3 specification and it too uses the same
definition so I suspect this is something that has been there for a long
- Why are `Object` and `new Object` specified differently?
- If there is no actual reason, can the definition be simplified for the
next version of the spec? (I think simplifying the spec is important and
Sorry if I'm missing something obvious.
Originally asked on Stack Overflow -
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss