Zac Anger's Blog

Javascript Operators

06 February, 2016

(Just a little cheatsheet/list for my own easy reference--and anyone else's, too, of course. This is like maybe 83 percent just copied from MDN.)

JAVASCRIPT OPERATORS

There are a whole whole bunch! Here's most of 'em, kinda hopefully split up and sorted in some sort of order that makes sense. It's always worth just taking a peek at the spec or MDN or whatever, especially it looks like actual standards are going to be getting actual changes within actual human lifespans now.


BITWISE:

LOGICAL:

ASSIGNMENT:

EQUALITY:

POSTFIX/PREFIX:

UNARY:

ARITHMETIC:

COMPARISON/RELATIONAL:


PRECEDENCE

Operators will be evaluated in a specific order. If there are operators that have the same priority, it's probably a good idea to check MDN or somesuch, because it's not all just left-to-right as one might expect. Here's a (very) cut-down list, in declining order (so the beginning of the list would be evaluated first, last operator in the list would be evaluated last). Grouping, new, postfix increment & decrement, NOT, prefix increment and decrement, unary plus and minus, multiplication and division, remainder, addition and subtraction, bitwise shifts, less than and greater than comparisons, all the equality/inequalities, bitwise and logical OR and AND (and bitwise XOR), the ternary (conditional), all your assignment operators, and then finally your spreads and sequences.

Submit a bug report