Variables are user-defined names that temporarily store data such as numbers, strings, or other objects (a string, a limit, a chart, a pivot, and so on). Variables can be created and defined when the variable is needed, or formally declared at the beginning of the script. Variables can be either local or global and have two important characteristics:
Name—Word used to identify the variable. A variable name must not be a reserved word and must start with a letter. Letters, numbers, or an underscore can be used in the name. Do not use periods, spaces or hyphens.
Data Type—Type of information stored in the variable, including:
Numbers—For example, 1 or 6.5777
Booleans—True or false
Strings—For example, Hyperion Solutions
null—Keyword which denotes a null value. The null value is also a primitive value.
undefined—Top-level property whose value is undefined. The undefined value is also a primitive value.
Note: | There is no method to distinguish explicitly between integer values (for example, 2) and real (floating point) numbers (for example, 3.14.). In addition, there is no date data type. However, you can use the Date object to handle date manipulations. |
JavaScript Basics introduces the use of variables in JavaScript scripts.