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.

Review<br />

The following points summarize what you should have learned by reading this book<br />

(and investigating the code examples). Read each summary, and if you don't<br />

understand what is being said, return to the topic in the book.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

An object is made up of named properties that store values.<br />

Most everything in <strong>JavaScript</strong> can act like an object. Complex values are objects,<br />

and primitive values can be treated like objects. This is why you may hear people<br />

say that everything in <strong>JavaScript</strong> is an object.<br />

Objects are created by invoking a constructor function with the new keyword, or by<br />

using a shorthand literal expression.<br />

Constructor functions are objects (Function() objects), thus, in <strong>JavaScript</strong>,<br />

objects create objects.<br />

<strong>JavaScript</strong> offers nine native constructor functions: Object(), Array(),<br />

String(), Number(), Boolean(), Function(), Date(), RegExp(), and Error().<br />

The String(), Number(), and Boolean() constructors are dual-purposed in<br />

providing a) primitive values and b) object wrappers when needed, so that<br />

primitive values can act like objects.<br />

The values null, undefined, "string", 10, true, and false are all primitive<br />

values, without an object nature unless treated like an object.<br />

When the Object(), Array(), String(), Number(), Boolean(), Function(),<br />

Date(), RegExp(), and Error() constructor functions are invoked using the new<br />

keyword, an object is created that is known as a "complex object" or "reference<br />

object."<br />

"string", 10, true, and false, in their primitive forms, have no object qualities<br />

until they are used as objects; then <strong>JavaScript</strong>, behind the scenes, creates<br />

temporary wrapper objects so that such values can act like objects.<br />

Primitive values are stored by value, and when copied, are literally copied.<br />

Complex object values on the other hand are stored by reference, and when<br />

copied, are copied by reference.<br />

Primitive values are equal to other primitive values when their values are equal,<br />

whereas complex objects are equal only when they reference the same value.<br />

141

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

Saved successfully!

Ooh no, something went wrong!