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