JS Tutorial



JS PRECEDENCE


JavaScript Operator Precedence βš–οΈ

Operator precedence determines the order in which operations are performed in an expression. Higher precedence operators are evaluated before lower precedence ones.

🧠 Basic Example

Consider the following expression:

let result = 10 + 5 * 2; // result is 20

Multiplication (*) has higher precedence than addition (+), so it’s evaluated first.

πŸ“‹ Precedence Table (Simplified)

  • Highest β†’ () (Parentheses)
  • ., [], () (Member access, function call)
  • ++, -- (Postfix)
  • !, typeof, ++, -- (Unary)
  • *, /, % (Multiplicative)
  • +, - (Additive)
  • <<, >> (Bitwise shift)
  • <, >, ==, === (Comparison)
  • &&, || (Logical)
  • = (Assignment)
  • Lowest β†’ , (Comma)

πŸ§ͺ Try It: Live Precedence Test

πŸ’‘ Use Parentheses!

Always use parentheses to make your expressions more readable and to ensure proper order of evaluation, especially when mixing multiple operators.

Note: Operator precedence can lead to unexpected results if not understood properly. It’s better to make things explicit with ().

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review