Object() (Function)

An Object object constructor.

Availability:

ECMAScript edition - 2
JavaScript - 1.1
JScript - 1.0
Internet Explorer - 3.02
Netscape - 3.0
Property/method value type:An object of a type that depends on the passed in argument
JavaScript syntax:-Object()
-Object(aValue)
Argument list:aValueA value to be stored in the new object

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.

ValueResult
No argumentCreates a new empty object as if new Object() had been called.
nullCreates a new empty object as if new Object(null) had been called.
undefinedCreates a new empty object as if new Object(undefined) had been called.
BooleanCreates a new boolean object whose default value is the input value.
NumberCreates a new number object whose default value is the input value.
StringCreates a new string object whose default value is the input value.
ObjectNo conversion, the input value is returned unchanged.

See also:Cast operator, Constructor function, constructor property, Implicit conversion, Object object

Cross-references:

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