Changes

Jump to: navigation, search

Introducing JavaScript Variables

16 bytes added, 18:50, 11 April 2007
Variable Declaration and the Assignment Operator
</pre>
In the first line above the variables ''i'', ''j'' and ''k'' are all defined but are not assigned initial values. The second line declared both ''myValue'' and ''myMessage'', initializing the variables with values. In the case of ''myMessage'' the variable is initialized with a string.
== JavaScript Variable Naming Conventions ==
JavaScript variable names are made up of letter, numbers and underscores. They cannot contain spaces and must not begin with a number. For example ''sales_percentage'' would be a valid variable name, where as ''sales percentage'' would be invalid because it contains a space character. Similarly ''two_layers'' is valid, but ''2_layers'' is not due to the fact that it begins with a number. JavaScript variable names can be of any length, although common sense should be used to ensure excessively long name are not used.

Navigation menu