More on JavaScript Operators

Read this article to learn more about using operators in JavaScript. We will not use all of them in this introductory course. However, this is a condensed reference that contains tables of all operator categories. JavaScript categorizes operators by the task (such as arithmetic, comparison, or assignment). Operators execute in a particular order. This is called operator precedence and tells JavaScript which part to evaluate first, second, third, and so on. This is an important concept. 

For example, consider how a program calculates a price using arithmetic operators:

Multiplication first the result is: $18 = 4 + 2 * 7 ( 2 * 7 = 14 + 4)
Calculate left to right the result is: $42 = 4 + 2 * 7 (4+ 2 = 6 * 7)

Operator precedence

The precedence of operators determines the order they are applied when evaluating an expression. You can override operator precedence by using parentheses.

The following table describes the precedence of operators, from highest to lowest.

Operator type Individual operators
member . []
call / create instance () new
negation/increment ! ~ - + ++ -- typeof void delete
multiply/divide * / %
addition/subtraction + -
bitwise shift << >> >>>
relational < <= > >= in instanceof
equality == != === !==
bitwise-and &
bitwise-xor ^
bitwise-or |
logical-and &&
logical-or ||
conditional ?:
assignment = += -= *= /= %= <<= >>= >>>= &= ^= |= &&= ||= ??=
comma ,