JavaScript always evaluates expressions in strictly left-to-right order.
In general, JavaScript expressions are evaluated in the following order:
- Parentheses
- Exponents
- Multiplication and division
- Addition and subtraction
- Relational operators
- Equality operators
- Logical AND
- Logical OR
It is important to understand the order in which expressions are evaluated in order to write code that works correctly.
Here are the most commonly used operators in JavaScript, ordered by precedence from highest to lowest:
- Grouping: ()
- Unary: +, -, !
- Multiplicative: *,/, %
- Additive: +, -
- Relational: <, >, <=, >=
- Equality: ==, != , ===, !==
- Logical AND: &&
- Logical OR: ||
Reference taken from here
Top comments (0)