JavaScript Operators and Precedence Quiz

Topics: Assignment, Comparison, Arithmetic, Bitwise, Ternary, Logical, and Unary operators

JavaScript Operators and Precedence

5 mins read

1. What is the output?

 let num = 8;
let multiplier = 2;
num *= multiplier += 3;
console.log(num);

2. What is the output?

  let a = "Hello";
let b = "hello";
let result = a < b;
console.log(result);

3. What is the output?

 let x = true;
let y = 5;
let result = x && (y > 10);
console.log(result);

4. What is the output?

 let name = "John";
let fallbackName = "Anonymous";
let result = name ?? fallbackName ?? "Guest";
console.log(result);

5. What is the output?

  let x = undefined;
let y;
let result = x === y;
console.log(result);

6. What is the output?

 let x = 5;
let y = 3;
x += y *= 2;
console.log(x);

7. What is the output?

 let price = 10;
let discount = null;
let finalPrice = price - (discount ?? 0);
console.log(finalPrice);

8. What is the output?


 let y = "Hello";
let result = y && "World";
console.log(result);

9. What is the output?

 let x;
let result = x !== null ? x : "Default";
console.log(result);