Javascript for Smart People

Variables

A variable is a place in memory used to store a value. You can use an identifier to label a variable. Variable names follow the same rules as legal identifiers. You can't use a keyword as an identifier. A variable can hold a number, string, or boolean value.

You can define a variable:

var num;
var str;
var booln;

You can initialize a variable with a value:

num = 0;
str = 'Hello world!';
booln = true;

A variable can be defined and initialized in one step:

var num = 0;
var str = 'Hello world!';
var booln = true;

"A variable is a place in memory used to store a value."