As in Mathematics, in JavaScript, the operators have a certain order of precedence. The table below presents the precedence of operators from highest to lowest.
Type of Operator | Example of Operators |
---|---|
Parentheses (overides others) | ( ) |
Unary (mathematical, logical, or bitwise) | – ++ — ! ~ typeof void delete |
Multiplication, Division, Modulus | * / % |
Addition, Subtraction | + – |
Shifts (bitwise) | >>> >> << |
Relational comparison | > >= < <= in instanceof |
Equality comparison | == != === !== |
AND (bitwise) | & |
XOR (bitwise) | ^ |
OR (bitwise) | | |
AND (logical) | && |
OR (logical) | || |
Conditional | ?: |
Assignment | = += -= *= /= %= <<= >>= >>>= &= ^= |= |
Comma | , |