Category | Subject | Sinopsys | Description | Example |
---|---|---|---|---|

Unary operations | -a | change the sign of a | ||

Unary operations | ~a | bitwise NOT a | ||

Unary operations | ++a | add 1 to a (before using a) | ||

Unary operations | a++ | add 1 to a (after using a) | ||

Unary operations | --a | subtract 1 from a (before using a) | ||

Unary operations | a-- | subtract 1 from a (after using a) | ||

Binary operations | a * b | multiply a by b | ||

Binary operations | a / b | divide a by b | ||

Binary operations | a % b | find the remainder of division of a by b | 13 % 5 Returns 3 | |

Binary operations | a + b | add a and b | ||

Binary operations | a - b | subtract b from a | ||

Binary operations | a & b | bitwise a AND b | ||

Binary operations | a | b | bitwise a OR b | ||

Binary operations | a ^ b | bitwise a XOR b | ||

Bitwise | a << b | shift a by b bits to the left (padding with zeros) | 9<<2 yields thirty-six, because 1001 shifted two bits to the left becomes 100100, which is thirty-six | |

Bitwise | a >> b | shift a by b bits to the right (copying the sign bit) | 9>>2 yields two, because 1001 shifted two bits to the right becomes 10, which is two | |

Bitwise | a >>> b | shift a by b bits to the right (padding with zeros) | 19>>>2 yields four, because 10011 shifted two bits to the right becomes 100, which is four. For non-negative numbers, zero-fill right shift and sign-propagating right shift yield the same result | |

Bitwise | a & b | AND: Returns a one in each bit position if bits of both operands are ones | 15 & 9 yields 9 (1111 & 1001 = 1001) | |

Bitwise | a | b | OR: Returns a one in a bit if bits of either operand is one | |

Bitwise | a ^ b | XOR: Returns a one in a bit position if bits of one but not both operands are one | 15 ^ 9 yields 6 (1111 ^ 1001 = 0110) | |

Bitwise | ~ a | NOT: Flips the bits of its operand | ||

Math | Math.abs(a) | the absolute value of a | ||

Math | Math.acos(a) | arc cosine of a | ||

Math | Math.asin(a) | arc sine of a | ||

Math | Math.atan(x) | Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians | ||

Math | Math.atan2(x,y) | Returns the angle theta of an (x,y) point as a numeric value between -PI and PI radians | ||

Math | Math.ceil(a) | integer closest to a and not less than a | ||

Math | Math.cos(a) | cosine of a | ||

Math | Math.exp(a) | exponent of a | ||

Math | Math.floor(a) | integer closest to and not greater than a | ||

Math | Math.log(x) | Returns the natural logarithm (base E) of a number | ||

Math | Math.max(a,b) | the maximum of a and b | ||

Math | Math.min(a,b) | the minimum of a and b | ||

Math | Math.pow(a,b) | a to the power b | ||

Math | Math.random() | Returns a random number between 0 and 1 | ||

Math | Math.round(a) | integer closest to a | ||

Math | Math.sin(a) | sine of a | ||

Math | Math.sqrt(a) | square root of a | ||

Math | Math.tan(a) | tangent of a | ||

Math | E | Returns Euler's constant (approx. 2.718) | ||

Math | LN2 | Returns the natural logarithm of 2 (approx. 0.693) | ||

Math | LN10 | Returns the natural logarithm of 10 (approx. 2.302 | ||

Math | LOG2E | Returns the base-2 logarithm of E (approx. 1.442) | ||

Math | LOG10E | Returns the base-10 logarithm of E (approx. 0.434) | ||

Math | PI | Returns PI (approx. 3.14159 | ||

Math | SQRT1_2 | Returns the square root of 1/2 (approx. 0.707) | ||

Math | SQRT2 | Returns the square root of 2 (approx. 1.414) |