Object() (Constructor)

An Object object constructor.


ECMAScript edition - 2
JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Object object
JavaScript syntax:-new Object
-new Object()
-new Object(aValue)
Argument list:aValueAn initial value for the new object

When Object is called as part of a new expression, it is a constructor that may create an object instance.

There are limitations what is sensible for the new operator to be able to do with the Object constructor. Since the Object is considered to be the highest ancestor of all objects in the prototype inheritance chain, you cannot logically have more than one Object object. Passing other native objects to the Object Constructor implies a type casting from their native object type to the Object type. That's not logical either. The main use of the Object Constructor then is to manufacturer object instantiations from non-object data types.

The table summarizes the resulting values from using the Object() constructor with the new operator.

No argumentCreates a new empty object
nullCreates a new empty object
undefinedCreates a new empty object
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
Native objectReturns the native object itself
Host objectHost implementation dependant behavior. Objects are cloned if necessary but some may not be.

Unless you assign the result of the new operation, an object will simply consume memory. You need to store a reference to it at the time it is instantiated. You can do this by assigning it to a variable or a property of another object, passing it into a function and making sure it gets retained in there, or storing it as an element in an array.


See also:Boolean(), Constructor function, constructor property, Garbage collection, Global object, Memory leak, new, Number(), Object constant, Object object, Object.prototype, Reference counting, String()


ECMA 262 edition 2 - section - 15.1.1

ECMA 262 edition 2 - section -

ECMA 262 edition 2 - section -

ECMA 262 edition 3 - section - 15.2.2