Variable
All declarations of the variable are unified into var. Either of the following is stored in this value : String, Number, Boolear, Object, null, undefined.
var i = 10;
// Definition of array
var a = [];
a[0] = 10;
a[1] = 20;
var a2 = [1000, true, "text"];
There are the following rules in a variable identifier.
- The first character is either an alphabetic character, underbar (_) and a dollar mark ($).
- It is an above-mentioned character or number after the 2nd character.
- An upper-case character and a lower-case character are differentiated.
- A reserved word cannot be used.
In order to store string type, you enclose a text with ['] or ["]. If it includes these signs in a text, you write it as [\'] and [\"]. Line feed, a tab sign, and the "\" itself are [\n], [\t], and [\\], respectively.