0% found this document useful (0 votes)
43 views

Operators: Arithmetic Relational / Comparison Operator Precedence

This document provides a summary of JavaScript operators including: - Arithmetic operators like addition and subtraction - Relational operators like greater than and less than - Operator precedence which determines the order of execution - Operator associativity which determines left to right parsing - A link to a table showing operator precedence and associativity - Coercion which converts data types so values can be compared

Uploaded by

Roniber Lugo J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Operators: Arithmetic Relational / Comparison Operator Precedence

This document provides a summary of JavaScript operators including: - Arithmetic operators like addition and subtraction - Relational operators like greater than and less than - Operator precedence which determines the order of execution - Operator associativity which determines left to right parsing - A link to a table showing operator precedence and associativity - Coercion which converts data types so values can be compared

Uploaded by

Roniber Lugo J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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