| operator | Description |
|---|---|
| v1 + v2 | Addition of numbers or strings addition |
| v1 - v2 | Subtraction of numbers |
| v1 * v2 | Multiplication of numbers |
| v1 / v2 | Division of numbers |
| v1 % v2 | Modulo (remainder after division v1/v2) |
| v1 ? v2 : v3 | If the v1 value is true, then the v2 value is returned, otherwise the v3 value is returned |
| v1++ | Increment of a number = increments a value by one (v1 = v1 + 1) |
| v1-- | Decrement of a number = decrements a value by one (v1 = v1 - 1) |
| v1 += v2; | Shortened notation for addition (v1 = v1 + v2) |
| v1 -= v2; | Shortened notation for subtraction (v1 = v1 - v2) |
| v1 *= v2; | Shortened notation for multiplication (v1 = v1 * v2) |
| v1 /= v2; | Shortened notation for division (v1 = v1 / v2) |
| +v1 | The + operator, which attempts to convert the operand (v1) to a number.
- If operand is a number, then the value of the operand is returned.
- If operand is a string (representing an integer or decimal number), then the value of this number is returned.
If the string is empty (""), then is converted to 0. - The If operand is of the bool type, then converts true to 1 and false to 0.
- null is converted to 0.
- If operand cannot be converted to a valid number, then the result will be the value NaN (Not-a-Number). |
var val;
val = 1 + 2;
// Returns 3
val = true + 1;
// Returns 2
val = false + false;
// Returns 0
val = 6 + "Boiler";
// Returns "6Boiler"
val = "Boiler" + false;
// Returns "Boilerfalse"
val = "Boiler" + "Valve";
// Returns "BoilerValve"
val = 12 % 5;
// Returns 2
val = -1 % 2;
// Returns -1
val = 1 % -2;
// Returns 1
val = -4 % 2;
// Returns -0
val = 5.5 % 2;
// Returns 1.5
val += 3.5;
// Shortened notation of the expression: val = val + 3.5;
val -= 6;
// Shortened notation of the expression: val = val - 6;| operator | Description |
|---|---|
| v1 == v2 | Returns true if v1 and v2 values are the same |
| v1 != v2 | Returns true if v1 and v2 values are not the same |
| v1 >= v2 | Returns true if v1 is greater or equal v2 |
| v1 > v2 | Returns true if v1 is greater than v2 |
| v1 <= v2 | Returns true if v1 is less then or equal v2 |
| v1 < v2 | Returns true if v1 is less than v2 |
var val;
val = 1 == 1;
// Returns true
val = 1 == "1";
// Returns true
val = "1" == 1;
// Returns true
val = 0 == false;
// Returns true
val = 1 != 2;
// Returns true
val = 1 != "1";
// Returns false
val = 1 != true;
// Returns false
val = 0 != false;
// Returns false| v1 && v2 | Logical AND (returns true if v1 and v2 is true) |
| v1 || v2 | Logical OR (returns true if v1 or v2 is true) |
| !v1 | Logical NOT (returns true if v1 is false) |
| operator | Description |
|---|---|
| v1 & v2 | Bitwise AND (each bit of return value is a result of AND operation of corresponding bits in v1 and v2) |
| v1 | v2 | Bitwise OR (each bit of return value is a result of OR operation of corresponding bits in v1 and v2) |
| v1 ^ v2 | Bitwise XOR (each bit of return value is a result of XOR operation of corresponding bits in v1 and v2 |
| ~v1 | Bitwise NOT (each bit of return value is the result of NOT operation of corresponding bit in v1). Not implemented in the PROMOTIC system so far. |
| v1 << v2 | Bitwise leftshift (the bit values in v1 are shifted by v2 number of bits to the left). For example v1<<2 returns double the v1 value. |
| v1 >> v2 | Bitwise rightshift (the bit values in v1 are shifted by v2 number of bits right). For example v1>>2 returns the whole number division of v1/2. |