23.04.2013 Views

javascript

javascript

javascript

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

isNaN<br />

Math<br />

NaN<br />

Number<br />

Object<br />

parseFloat<br />

parseInt<br />

RangeError<br />

ReferenceError<br />

RegExp<br />

String<br />

SyntaxError<br />

TypeError<br />

undefined<br />

unescape<br />

URIError<br />

■ Note If you are curious about the ECMAScript standard, visit http://www.ecmascript.org.<br />

Creating an Object Literal<br />

CHAPTER 1 ■ REPRESENTING DATA WITH VALUES<br />

The object value type provides a way for you to create a place in memory for related values, which may<br />

be named with an identifier or string. Those related values are referred to as members. So, we say an<br />

object contains members.<br />

Alright, click Clear in both Firebug panels. Then create an empty object literal named iceCream by<br />

keying in a pair of curly braces, followed of course by a semicolon.<br />

var iceCream = {<br />

};<br />

Now add a member named "Chocolate Fudge Brownie" followed by an expression with the number<br />

of calories per pint. Just like variables, members may contain a literal value or an expression for a value.<br />

Note that the name of the member is separated from the value by a colon.<br />

var iceCream = {<br />

"Chocolate Fudge Brownie": 4 * 260<br />

};<br />

OK, now members are separated by a comma. So to add a second member, follow the first one with<br />

a comma, like so:<br />

var iceCream = {<br />

"Chocolate Fudge Brownie": 4 * 260,<br />

"Half Baked": 4 * 250<br />

};<br />

Now there are several more members so that we have ten in all. Just remember to separate them<br />

with a comma. But don’t follow the final member—"Mission to Marzipan"—with a comma.<br />

9

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

Saved successfully!

Ooh no, something went wrong!