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
Following are the members of the Object constructor:
|
Property/method |
Description... |
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime