- Statements should end in a semicolon (;).
- Must be defined before being used. The variable name can contain A – Z, a – z, underscore or digits and must start with a letter or an underscore (“_”).
- Assume the type of the data that is put into the variable. The data type does not have to be explicitly defined
- Are global variables when defined outside of a function, and are available anywhere in the current script context. Variables created within a function are local variables, and can be used only within that function.
- Strings have to be enclosed in quotation marks, either a single or double. For example:
print(”Hello ” + ‘world ‘+ Country.name)produces the following: Hello world US.
- To increment a variable, such as a = a + 1, you can use a++. You can decrement a variable in the same way, as in a–.
- To enter comments in the script, use “//” to start a single line comment or the combination of “/*” and “*/” to enclose a multi-line comment.
- Values that are not defined as a data type (string, number, Boolean) may be defined as an object, such as Date, Array, Boolean, String, and Number. As an example you could define:
var ArrayList=new Array(”test”, ” this”, ” list”);.