A variable is a named portion of memory. Variables are used to store information that a program needs, such as a user's name, throughout the duration of the program.
JavaScripts variable types include:
Declaring variables
Before a variable can be used, it must be declared. Declaring a variable reserves memory and a namespace for the variable. To declare a variable, use the 'var' keyword, followed by the name you wish to assign the variable.
Statements
At the simplest level, a JavaScript statement is an instruction to the computer to perform a specific task. However, sometimes you will find that you need to execute several statements where JavaScript expects only one statement. To execute multiple statements in these cases, you must enclose the statements in curly brackets ( {} ).
Although whitespaces do not affect the execution of JavaScript, they should be used to make your code more readable. The convention that I will follow throughout these examples is to indent code blocks (code enclosed in curly-brackets) by one tab space.