Two numbers |
A number |
a + b |
The sum of a and b |
Two numbers |
A number |
a * b |
The product of a and b |
Two numbers |
A number |
a - b |
The difference between a and b |
Two numbers |
A number |
a / b |
The quotient of a and b |
Two numbers |
A number |
a % b |
The remainder left over after dividing a by
b
|
Two numbers |
A number |
a ** b |
The result of raising a to the b th
power.
|
Two numbers |
A number |
Math.max(a, b) |
The larger of a and b |
Two numbers |
A number |
Math.max(a, b) |
The smaller of a and b |
A number |
A number |
Math.abs(n) |
The positive version of n |
A number |
A number |
Math.sqrt(n) |
The square root of n |
A number |
A number |
Math.floor(n) |
n rounded down to an integer. |
A number |
A number |
Math.ceil(n) |
n rounded up to an integer. |
Nothing |
A number |
Math.random() |
A random number between 0 and 1 |
Two numbers |
A boolean |
a < b |
Whether a is less than b |
Two numbers |
A boolean |
a > b |
Whether a is greater than b |
Two numbers |
A boolean |
a <= b |
Whether a is less than or equal to b
|
Two numbers |
A boolean |
a >= b |
Whether a is greater than or equal to b
|
Two booleans |
A boolean |
a && b |
Whether a and b are true |
Two booleans |
A boolean |
a || b |
Whether either a or b is true (or both)
|
One boolean |
A boolean |
!a |
The opposite boolean value of a |
Any two values |
A boolean |
a === b |
Whether a and b are the same |
Any two values |
A boolean |
a !== b |
Whether a and b are not the same |
A string |
A number |
s.length |
The length of the s . Also one greater than the
largest legal index into s .
|
Two strings |
A number |
s.indexOf(x) |
The index of the first occurence of x in
s or -1 if there is none.
|
Two strings |
A string |
s1 + s2 |
The string created by concatenating s1 and
s2 .
|
A string and any other value |
A string |
s + x |
The string created by concatenating s with the string
representation of x .
|
A string and a number |
A string |
s[i] |
The one character in s at index i |
A string and a number |
A string |
s.slice(i) |
The part of s starting at i up to the
end of the string.
|
A string and two numbers |
A string |
s.slice(i, end) |
The part of s starting at i and ending
at end
|
A string |
A string |
s.toUpperCase() |
A string with the same contents as s but in all upper
case.
|
A string |
A string |
s.toLowerCase() |
A string with the same contents as s but in all lower
case.
|