Let’s learn a very interesting concept in JavaScript which defines which operation will be performed first when there are multiple operators in an expression. This also helps the translator to decide which operator should be given preference over others while evaluating the expression.
Precedence determines the way in which operators are given priority amongst each other. An operator with higher precedence is evaluated before an operator of lower precedence.
Well that was interesting, wasn’t it? It’s always fun to know how the code that you have written actually works behind-the-scenes. This is also a stepping stone towards becoming better programmers.
Now what do you think will happen when the operators of same precedence are present in an expression. This isn't as simple as you may think.
Associativity determines the way in which operators of the same precedence are evaluated.
To look at the table containing the precedence and associativity of all operators, check out this link below from the MDN documentation.