HTML and CSS Reference
In-Depth Information
Figure 12-3: Using the <output> tag for calculations in Opera browser.
In this brief snapshot of JavaScript, we've looked at a great deal, so if some of it escapes you,
don't worry. Most of what you need to know about JavaScript in the context of HTML5 is
working with the DOM. In this section, I show you how data are temporarily stored in your
computer's memory when looking at a Web page. Users can enter data by clicking a button, a
check box, a radio button, or a link, or by using the keyboard. (All of this will be related to
what happens with the DOM — trust me.)
In order to use the information that users enter, JavaScript has ways to both store it in
memory and make it available later in the session. By examining the dif erent structures in
JavaScript, you can get a sense of how this happens.
A variable is something that changes — it varies. You can think of a variable as a box with a
label on it. For example, you might have a box with the label “MobilePhone.” In the box, you
can place only one thing. You can change what's in the box — what we call the box's value. So,
if you have iPhone in your MobilePhone box, you can take it out and put in either a dif erent
iPhone (a newer model) or a dif erent phone such as an Android. Now, the box has a dif erent
value. h e label-value pair (or name-value pair) is the combination of the variable's label and
its current value.
You don't have to put in the name of a mobile phone in the MobilePhone box. You can put in
anything you want — a tin-can walkie-talkie or a pink elephant. Assign whatever value you
want and any type of value, including another variable. If I wanted, I could put in a number — a
real number, not just one that identii es something such as a street address. However, a good
and practical practice is to use variable names that can be associated with what you expect to
Search WWH ::

Custom Search