Type: | Number | String | Boolean |
Examples: | 1 1024 18.0 3.14159 1.024e3 |
"" "foo" "2 words" |
true false |
Variables:
A variable is a symbolic name for an unspecified value in an expression or statement. A variable can be used in any situation where the data that it refers to can be used. A variable name can refer to any of the data types, described above. Variables are given values by using the assignment operator as described below. All of the examples below make use of variables (e.g. x, y, Str, flag, etc...)
The following lists identify variable names that should be avoided because they are already used by JavaScript or the browser.
Operators:
Operator
Name
Data Types
Expressions
Values
+
Addition or
ConcatenationNumber
String3 + 1
4 + 7.432
"foo" + "bar"4
11.432
"foobar"
-
Subtraction
Number
7 - 2
5 - 3.3595
1.641
*
Multiplication
Number
2 * 5
10 * 9.77310
97.73
/
Division
Number
10 / 4
2.5 / 82.5
0.3125
%
Remainder
Number
10 % 4
2 % 0.752
0.5
&&
AND
Boolean
true && true
true && false
false && true
false && falsetrue
false
false
false
||
OR
Boolean
true || true
true || false
false || true
false || falsetrue
true
true
false
!
NOT
Boolean
!true
!falsefalse
true
Comparison:
Operator
Name
Data Types
Examples
==
Equality
Number
String
Boolean3 == 3
"test" == "test"
false == false
!=
Inequality
Number
String
Boolean12 != 39
"foo" != "bar"
false != true
<
Less Than
Number
String12 < 3.1415
"a" < "b"
<=
Less Than or Equal
Number
String117 <= 17
"ABC" <= "ABD"
>
Greater Than
Number
String112 > -4
"foo" > "bar"
>=
Greater Than or Equal
Number
String13.99 >= 3.98
"fool" >= "foo"
1. Strings follow standard dictionary ordering, i.e.,
"A" < "B" < ... < "Z" < "a" < "b" ... < "z"
  "a" < "aa" < ... < "ab" < "aba" < ... < "b"
Statements:
Statement Name
General Form
Examples
Comment
Assignment Statement
The value of the expression on the right-hand side is assigned to the variable
on the left-hand side.
If-Then Statement