Operator precedence determines the order in which operations are performed in an expression. Higher precedence operators are evaluated before lower precedence ones.
Consider the following expression:
let result = 10 + 5 * 2; // result is 20
Multiplication (*
) has higher precedence than addition (+
), so itβs evaluated first.
()
(Parentheses).
, []
, ()
(Member access, function call)++
, --
(Postfix)!
, typeof
, ++
, --
(Unary)*
, /
, %
(Multiplicative)+
, -
(Additive)<<
, >>
(Bitwise shift)<
, >
, ==
, ===
(Comparison)&&
, ||
(Logical)=
(Assignment),
(Comma)Always use parentheses to make your expressions more readable and to ensure proper order of evaluation, especially when mixing multiple operators.
()
.
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!