The first character must be:
- a letter
- an underscore (_)
- a dollar sign ($)
Subsequent characters may be:
- underscores (_)
- dollar signs ($)
Do not start names with a $ sign.
- Historically, programmers have used different ways of joining multiple words into one variable name:
|Upper Camel Case (Pascal Case)||FirstName|
|Lower Camel Case||firstName|
- It's a good programming practice to declare all variables at the beginning of a script.
var carName1; //A variable declared without a value will have the value **undefined**. var carName2 = "Volvo"; var person = "John Doe", carName3 = "Volvo", price = 200;
var x; console.log(x); x = "123"; console.log(x); var x; console.log(x);
undefined 123 123