Open Playground
JS TutorialLesson #130

JavaScript Operator Precedence

Operator precedence describes the order in which operations are performed in an arithmetic expression.

Order of Operation

Operator precedence describes the order in which operations are performed in an arithmetic expression.

Multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-).

Examples

Example Code

javascript
Try it Yourself
let x = 100 + 50 * 3;
Operator Precedence Values Expressions in parentheses are computed before the rest of the expression Functions are executed before the result is used in the rest of the expression
Val
18
17
17
17
17
17
16
Increment Operators Postfix increments are executed before prefix increments
15
15
14
14
NOT Operators
14
14
Unary Operators
14
14
14
14
Arithmetic Operators Exponentiations are executed before multiplications Multiplications and divisions are executed before additions and subtractions
13
12
12
12
11
11
11
Shift Operators
10
10
10
Relational Operators
9
9
Comparison Operators
9
9
9
9
8
8
8
8
Bitwise Operators
7
6
5
Logical Operators
4
3
3
Conditional (ternary) Operator
2
Assignment Operators Assignments are executed after other operations
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1


Interactive Code Examples

Examples

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
let x = 100 + 50 * 3;