% is the remainder operator which is the same as modulo.
Values are assigned using
=, and there are also compound assignment statements such as
-=. These extend out to
x = x operator y.
x += 5; x = x + 5;
You can use
-- to increment and decrement respectively. These can be used as a prefix or postfix operators.
+ operator also does string concatenation:
'hello' + ' world'; // "hello world"
If you add a string to a number (or other value) everything is converted into a string first. This might trip you up:
'3' + 4 + 5; // "345" 3 + 4 + '5'; // "75"
Adding an empty string to something is a useful way of converting it to a string itself.
>=. These work for both strings and numbers. Equality is a little less straightforward. The double-equals operator performs type coercion if you give it different types, with sometimes interesting results:
123 == '123'; // true 1 == true; // true
To avoid type coercion, use the triple-equals operator:
123 === '123'; // false 1 === true; // false
There are also