Object
Object()
is a constructor that creates objects, for example:
> var o = new Object();
This is the same as using the object literal:
> var o = {}; // recommended
You can pass anything to the constructor and it will try to guess what it is and use a more appropriate constructor. For example, passing a string to new Object()
will be the same as using the new String()
constructor. This is not a recommended practice (it's better to be explicit than let guesses creep in), but still possible.
> var o = new Object('something'); > o.constructor; function String() { [native code] } > var o = new Object(123); > o.constructor; function Number() { [native code] }
All other objects, built-in or custom, inherit from Object
. So, the properties and methods listed in the following sections apply to all types of objects.
Members of the Object constructor
Have a look at the following table:
Property/method |
Description |
---|---|
|
The prototype of all objects (also... |