JavaScript Operators & Expressions Quiz
A detailed JavaScript quiz exploring arithmetic, comparison, logical, bitwise, and assignment operators through practical expressions and tricky evaluation scenarios.
Question 1
What is the result of the following expression?
console.log(2 + 3 * 4)Question 2
How does grouping affect the result?
console.log((2 + 3) * 4)Question 3
What value is logged?
let total = 10
total += 5
console.log(total)Question 4
What does this expression output?
let x = 5
console.log(x++)Question 5
What value will appear in the console?
let y = 5
console.log(++y)Question 6
What result does exponentiation produce here?
console.log(2 ** 3 ** 2)Question 7
What is the remainder of this division?
console.log(5 % 2)Question 8
How does JavaScript handle negative operands with modulo?
console.log(-5 % 2)Question 9
What is logged when dividing by zero?
console.log(10 / 0)Question 10
How does JavaScript evaluate 0 divided by 0?
console.log(0 / 0)Question 11
What string is produced by this concatenation?
const result = '5' + 3
console.log(result)Question 12
What number results from this subtraction?
const result = '5' - 3
console.log(result)Question 13
What is the numeric total?
console.log(true + true)Question 14
How does multiplication behave with numeric strings?
console.log('5' * '2')Question 15
What is the outcome of this expression?
console.log('5' + +'2')Question 16
What value remains after subtraction assignment?
let a = 10
a -= 4
console.log(a)Question 17
How is this compound assignment evaluated?
let value = 3
value *= 2 + 4
console.log(value)Question 18
What value does the division assignment produce?
let base = 16
base /= 2 ** 2
console.log(base)Question 19
What is the bitwise AND of these numbers?
const result = 5 & 3
console.log(result)Question 20
What is the bitwise OR result?
const result = 5 | 3
console.log(result)Question 21
What number does bitwise XOR yield?
const result = 5 ^ 3
console.log(result)Question 22
How does the bitwise NOT operator transform 5?
console.log(~5)Question 23
What value does this left shift produce?
console.log(1 << 3)Question 24
What is the outcome of this right shift?
console.log(8 >> 2)Question 25
What number results from the zero-fill right shift?
console.log(-9 >>> 1)Question 26
What does this chained comparison evaluate to?
console.log(3 > 2 > 1)Question 27
How does grouping change the previous comparison?
console.log(3 > (2 > 1))Question 28
How does loose equality behave?
console.log('5' == 5)Question 29
How does strict equality behave with different types?
console.log('5' === 5)Question 30
How are null and undefined compared loosely?
console.log(null == undefined)Question 31
What is the result of this relational comparison?
console.log(null >= 0)Question 32
Does loose equality consider null equal to zero?
console.log(null == 0)Question 33
How are strings compared lexicographically?
console.log('abc' < 'abd')Question 34
What happens with numeric strings of different lengths?
console.log('10' > '2')Question 35
How does NaN behave with equality?
console.log(NaN == NaN)Question 36
Which method correctly detects NaN?
console.log(Number.isNaN(NaN))Question 37
What boolean does this coercion produce?
console.log(!!'0')Question 38
What value results from this logical expression?
console.log(!0 && 5)Question 39
What value does this OR operation return?
console.log(0 || 'fallback')Question 40
How does logical AND short-circuit here?
console.log('value' && 0)Question 41
What does the logical OR assignment operator do in this case?
let score = 0
score ||= 10
console.log(score)Question 42
How does logical AND assignment behave with a truthy value?
let attempts = 1
attempts &&= 5
console.log(attempts)Question 43
What does nullish coalescing assignment yield here?
let input = null
input ??= 'default'
console.log(input)Question 44
What does the nullish coalescing operator return?
console.log(null ?? 'backup')Question 45
How does nullish coalescing treat zero?
console.log(0 ?? 5)Question 46
What value is produced here?
const result = undefined ?? 10
console.log(result)Question 47
How does optional chaining interact with nullish coalescing?
const obj = null
const value = obj?.prop ?? 'none'
console.log(value)Question 48
What does this ternary expression output?
const result = 5 > 3 ? 'yes' : 'no'
console.log(result)Question 49
How does the ternary operator treat falsy values?
const result = 0 ? 'truthy' : 'falsy'
console.log(result)Question 50
What does the comma operator return?
console.log((2, 4, 6))