📊 JavaScript Operator Precedence

Last Updated: 12th October 2025


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

🗣 Hinglish Tip: Jaise maths me * aur / pehle hota hai aur + aur - baad me, waise hi JS me operators ka order hota hai.


🧩 Precedence Table (Top to Bottom)

OperatorDescriptionExample
()Parentheses (grouping)(2 + 3) * 4 → 20
++, -- (postfix)Increment/Decrement after valuex++
++, -- (prefix), +, -, ~, !Unary operators++x, -5, !true
**, **=Exponentiation2 ** 3 → 8
*, /, %Multiplication, Division, Modulus5 * 3 → 15
+, -Addition, Subtraction2 + 3 → 5
<<, >>, >>>Bitwise shifts5 >> 1 → 10
<, <=, >, >=, in, instanceofComparison5 > 3 → true
==, !=, ===, !==Equality / Strict Equality5 === '5' → false
&Bitwise AND5 & 1 → 1
^Bitwise XOR5 ^ 1 → 4
|Bitwise OR5 | 1 → 5
&&Logical ANDtrue && false → false
||Logical ORtrue || false → true
??Nullish Coalescingnull ?? 5 → 5
? : Ternary Conditional5 > 3 ? "Yes" : "No" → Yes
=, +=, -=, *=, /=, %=, **=, &=, |=, ^=, <<=, >>=, >>>=Assignment operatorsx = 5
,Comma operator(a=1, b=2) → 2

✏ Mini Examples

let a = 2 + 3 * 4; // Multiplication first → 2 + 12 = 14
let b = (2 + 3) * 4; // Parentheses first → 5 * 4 = 20
let c = (true && false) || true; // && first → false || true → true
let d = null ?? 10; // Nullish coalescing → 10
let e = 5 > 3 ? "Yes" : "No"; // Ternary → Yes

console.log(a, b, c, d, e); // Output: 14 20 true 10 Yes

🗣 Hinglish Tip: Jab confusion ho → use parentheses. Ye hamesha safe aur readable hota hai.


💡 Quick Practice

  1. Calculate 3 + 4 * 2 / (1 - 5) ** 2 step by step.
  2. Predict output of true || false && false.
  3. Check what null ?? "default" gives.
  4. Write a ternary for age >= 18 ? "Adult" : "Minor".