The Object Constructor can be called as a function. When this happens, the value passed in undergoes a type conversion.
In an ECMA-compliant implementation, the Object constructor function uses the ToObject conversion. However it handles input values undefined and null as special cases and creates a new object as if the constructor had been used with the new operator.
The table summarizes the results based on the input value data types.
Value | Result |
---|---|
No argument | Creates a new empty object as if new Object() had been called. |
null | Creates a new empty object as if new Object(null) had been called. |
undefined | Creates a new empty object as if new Object(undefined) had been called. |
Boolean | Creates a new boolean object whose default value is the input value. |
Number | Creates a new number object whose default value is the input value. |
String | Creates a new string object whose default value is the input value. |
Object | No conversion, the input value is returned unchanged. |
ECMA 262 edition 2 - section - 15.1.1
ECMA 262 edition 2 - section - 15.1.3.1
ECMA 262 edition 2 - section - 15.2.2.2
ECMA 262 edition 3 - section - 15.2
Prev | Home | Next |
Object() | Up | Object.__parent__ |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |