You are on page 1of 1

< > iLoveCoding

JavaScript Cheatsheet
Page 4

Learn JavaScript Correctly (Video course) https://ilovecoding.org/courses/js2

Full list of JavaScript operators https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators


6 Operators
Operators are reserved-words that perform action on values and variables.

Arithmetic Relational / Comparison Operator Precedence


.. + .. Add .. >= .. Greater than or equal to Given multiple operators are used in an expression, the "Operator
.. - .. Subtract .. <= .. Less than or equal to Precedence" determines which operator will be executed first. The
.. * .. Multiply .. != .. Not equal after coercion higher the precedence, the earlier it will get executed.
.. / .. Divide .. !== .. Not equal
.. % .. Remainder Operator Associativity
.. ** .. Exponential Increment / Decrement Given multiple operators have the same precedence, "Associativity"
..++ Postfix increment determines in which direction the code will be parsed.
Assignment ..-- Postfix decrement
.. = .. Assign value See the Operator Precedence and Associativity table here:
.. += .. Add then assign ++.. Prefix increment http://bit.ly/operatortable
.. -= .. Subtract then assign --.. Prefix increment
.. *= .. Multiply then assign
Others 7 Coercion
Logical typeof ..
When trying to compare different "types", the JavaScript engine
.. || .. Or .. instanceof ..
attempts to convert one type into another so it can compare the two
.. && .. And (..)
values.
...spread-operator
Equality . Type coercion priority order:
.. === .. Equality ..[..] 2 + "7"; // "27"
1. String
.. == .. Equality with coercion new .. 2. Number true - 5 // -4
delete .. 3. Boolean
Conversion ( .. ? .. : .. )
+ .. Convert to number Coercion in action
- .. Convert to number then negate it Does this make sense?
! .. Convert to boolean then inverse it
iLoveCoding
"Don't just learn JavaScript - Become a Full-Stack JavaScript Developer" https://iLoveCoding.org

You might also like