Chapter 2

Understanding Variables

IN THIS CHAPTER

Bullet Getting your head around variables

Bullet Assigning names to variables

Bullet Introducing JavaScript data types

Bullet Figuring out numbers

Bullet Stringing strings together

One man's constant is another man's variable.

—ALAN PERLIS

You may have heard about — or perhaps even know — people who, through mishap or misfortune, have lost the ability to retain short-term memories. If you introduce yourself to one of these folks, they’ll be asking you your name again five minutes later. They live in a perpetual present, experiencing the world anew every minute of every day.

What, I’m sure you’re asking yourself by now, can any of the above possibly have to do with coding? Just that, by default, your JavaScript programs also live a life without short-term memory. The web browser executes your code one statement at a time until there are no more statements left to process. It all happens in the perpetual present. Ah, but notice that I refer to this lack of short-term ...

Get HTML, CSS, & JavaScript All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.