Feb 15

Understanding Variables II

Programming by Imam | No Comments »

Using Some Fancy Characters

  Advanced

You may not need to know about the special fancy characters known as escape sequences (or escape characters), but they sure are useful—and fun! Strictly speaking, it’s not necessary to learn about escape sequences to learn how to program. But most languages use them, and they make some tasks much easier.

All the JavaScript escape sequences begin with a backslash (\).

Escape Sequence Meaning
\b Backspace
\t Tab
\n New line
\f Form feed
\h Hexadecimal sequence
\r Carriage return
\u Unicode sequence (see http://www.unicode.org for more information about Unicode)
\” Double quote
\’ Single quote
\\ Backslash (\)

Popularity: 3% [?]

Feb 14

Understanding Variables

Programming by Imam | No Comments »

Just a moment ago, I explained types by asking you to imagine you had three buckets—one for sand, one for water, and one for pebbles—to build a sand castle. The types were sand, water, and pebbles. The buckets are the variables. In other words, a variable is used to hold values (with the kinds of values limited by the kinds of types). So you can think of a variable as a placeholder for data. As such, variables are an important underlying part of any computer program. If you just have a value—for example, the number 42—you can perform operations on that particular number. But if you have a variable that holds numerical values, you can invent an operation once—and then apply it to a whole mess of values.

Popularity: 3% [?]