17.11.2015 Views

JavaScript_Succinctly

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Object() properties and methods<br />

The Object() object has the following properties (not including inherited properties and<br />

methods):<br />

Properties (e.g., Object.prototype;):<br />

prototype<br />

Object() object instance properties and methods<br />

Object() object instances have the following properties and methods (does not include<br />

inherited properties and methods):<br />

Instance Properties (e.g., var myObject = {}; myObject.constructor;):<br />

constructor<br />

Instance Methods (e.g., var myObject = {}; myObject.toString();):<br />

hasOwnProperty()<br />

isPrototypeOf()<br />

propertyIsEnumerable()<br />

toLocaleString()<br />

toString()<br />

valueOf()<br />

Notes<br />

The prototype chain ends with Object.prototype, and thus all of the properties and<br />

methods of Object() are inherited by all <strong>JavaScript</strong> objects.<br />

Creating Object() objects using "object literals"<br />

Creating an "object literal" entails instantiating an object with or without properties using<br />

braces (e.g., var cody = {};). Remember at the beginning of Chapter 1 when we<br />

created the one-off cody object and then gave the cody object properties using dot<br />

notation? Let's do that again.<br />

85

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!