| Data Type | Examples |
| Number | 1 1024 18.0 3.14159 1.024e3 |
| String | "" "foo" "2 words" |
| Boolean | true false |
| Operator | Name | Data Types | Examples | Result |
| = | Assignment | Number String Boolean |
x = 3; y = 7.654; Str = "foo"; flag = true; |
x == 3 y == 7.654 Str == "foo" flag == true |
| + | Addition | Number String |
x = 4 + 3; y = x + 7.432; Str = "foo" + "bar"; |
x == 7 y == 14.432 Str == "foobar" |
| - | Subtraction | Number | x = 7 - 2; y = x - 3.359; |
w == 5 y == 1.641 |
| * | Multiplication | Number | x = 2 * 5; y = x * 9.773; |
x == 10 y == 97.73 |
| / | Division | Number | x = 10 / 4; y = x / 8; |
x == 2.5 y == .3125 |
| % | Remainder1 | Number | x = 10 % 4; y = x % .75; |
x == 2 y == .5 |
| ++ | Increment | Number | x++; | x = x + 1 |
| -- | Decrement | Number | y--; | y = y - 1 |
| && | AND | Boolean | flag = true; D = true && flag; D = D && false; |
flag == true D == true D == false |
| || | OR | Boolean | flag = true; D = flag || true; D = false || D; |
flag == true D == true D == false |
| ! | NOT | Boolean | D = !true; D = !D; |
D == false D == true |
| 1. The Remainder operator is often also called the Modulus operator. | ||||
| Operator | Name | Data Types | Examples |
| == | Equality | Number String Boolean |
3 == 3 "test" == "test" false == false |
| != | Inequality | Number String Boolean |
12 != 39 "foo" != "bar" false != true |
| < | Less Than | Number String1 |
2 < 3.1415 "a" < "b" |
| <= | Less Than or Equal | Number String1 |
17 <= 17 "ABC" <= "ABD" |
| > | Greater Than | Number String1 |
12 > -4 "foo" > "bar" |
| >= | Greater Than or Equal | Number String1 |
3.99 >= 3.98 "fool" >= "foo" |
|
1. Strings follow standard dictionary ordering, i.e., "A" < "B" < ... < "Z" < "a" < "b" ... < "z"   "a" < "aa" < ... < "ab" < "aba" < ... < "b" | |||
| Statement Name | General Form | Examples |
| Comment | ||
| For Loop |
|
|
| If-Then Statement |
|
|
| While Loop |
|
| Function | Examples | Result |
| Square Root | x = Math.sqrt(9); | x == 3 |
| Absolute Value | x = Math.abs(-23); y = Math.abs(99); |
x == 23 y == 99 |
| Maximum | x = Math.max(3,14); | x == 14 |
| Minimum | x = Math.min(3,14); | x == 3 |
| Power | x = Math.pow(2,3); | x == 8 |
| Floor | x = Math.floor(3.14159); y = Math.floor(4.5623); |
x == 3 y == 4 |
| Ceiling | x = Math.ceil(3.14159); y = Math.ceil(4.5623); |
x == 4 y == 5 |
| Round | x = Math.round(3.14159); y = Math.round(4.5623); |
x == 3 y == 5 |
| Parse Float | x = parseFloat("12.8"); y = parseFloat("ABC"); |
x == 12.8 y == NaN |
| Prompt |
theName = prompt("Enter Your Name:","Default Value");
Netscape will display the following dialog box, and theName will be assigned the value that is entered in the text field. ![]() | |
| Write | document.write("Howdy"); document.write(2+3); |
displays "Howdy" displays 5 |
| Action | General Form | Examples |
| Function Definition |
|
|
| Function Call |
|
|