⏱ 0:01est. 3 min
Chapter 22- Operators Precedence and Associativity
Notes
#BIGWORD Operator precedence - Which function gets called first. Functions are called in order of precedence (Higher precedence wins)
#BIGWORD Associativity - What order operator functions get called in : Left to right or right to left (When functions have the same precedence)
Example 1
var a = 3 + 4 * 5;
console.log(a); //23
---------------------------------------------------------------------------------------------
Example 2
var a=2 , b =3 , c=4;
a = b = c ;
console.log(a); //4
console.log(b); //4
console.log(c); //4
They all are equal because of associativity.
---------------------------------------------------------------------------------------------
Example 3
var a = (3 + 4) * 5;
console.log(a); //35
Brackets have higher precedence