JavaScript Boolean Logic & Truthy/Falsy Quiz
Explore 50 JavaScript questions covering boolean values, logical operators, comparison pitfalls, truthy/falsy coercion, short-circuit flow, optional chaining, nullish coalescing, ternaries, and real-world conditional patterns.
Question 1
What are the only boolean literal values in JavaScript?
Question 2
What does the typeof operator return for a boolean literal?
console.log(typeof true)Question 3
Which built-in function converts any value into an explicit boolean?
Question 4
What does the Boolean constructor return when called without new on an empty string?
console.log(Boolean(''))Question 5
Which statement accurately describes primitive booleans vs Boolean objects?
Question 6
What does the logical AND (&&) operator return?
Question 7
Given the code, what logs to the console?
console.log('A' && 0 && 'B')Question 8
What does the logical OR (||) operator return?
Question 9
What prints for the following OR expression?
console.log(null || 'fallback' || 42)Question 10
What is the outcome of applying the logical NOT (!) to a truthy value?
Question 11
Which comparison operator checks value and type equality without coercion?
Question 12
What does this comparison output?
console.log(0 == false)Question 13
What does the strict equality comparison log?
console.log('0' === 0)Question 14
Which expression evaluates to true?
Question 15
How does JavaScript compare booleans to numbers with > or < operators?
Question 16
Which list contains only falsy values in JavaScript?
Question 17
What is the boolean value of an empty array?
console.log(Boolean([]))Question 18
Which value is truthy?
Question 19
What does the following log?
const value = ' ';
console.log(Boolean(value))Question 20
Which value remains falsy even after JSON parsing?
Question 21
What is short-circuit evaluation?
Question 22
What prints in this short-circuit example?
let calls = 0;
const left = () => (++calls, false);
const right = () => (++calls, true);
left() && right();
console.log(calls)Question 23
How can logical AND be used for conditional execution?
Question 24
What does the OR operator commonly replace in defaulting logic?
Question 25
What is a drawback of using || for defaults?
Question 26
What does the double NOT (!!) operator do?
Question 27
What logs to the console?
const input = 'hello';
console.log(!!input)Question 28
Which option shows coercion of a number into a boolean without using !! or Boolean()?
Question 29
What is the boolean result of applying !! to NaN?
Question 30
When using the Boolean wrapper with new, what type does the result have?
Question 31
What value logs from this conditional?
const flag = '';
if (flag) {
console.log('truthy');
} else {
console.log('falsy');
}Question 32
What does the ternary operator return?
Question 33
What prints from this ternary expression?
const score = 0;
const label = score ? 'Positive' : 'Zero or Negative';
console.log(label)Question 34
How can you guard against executing a function when a reference might be undefined?
Question 35
What is a common readability improvement over nested ternaries?
Question 36
What does Array.prototype.some return?
Question 37
What prints here?
const fruits = [];
if (fruits) {
console.log('has array');
}Question 38
How can you check if an object has any own enumerable properties before acting?
Question 39
What boolean value does Array.prototype.includes return?
Question 40
Why might you wrap optional property access in Boolean()?
Question 41
What does optional chaining (?.) prevent?
Question 42
What logs here?
const config = null;
console.log(config?.mode)Question 43
How does nullish coalescing (??) differ from logical OR?
Question 44
What is printed?
const qty = 0;
console.log(qty ?? 10)Question 45
Which expression safely calls an optional method only if it exists?
Question 46
Why can comparing arrays with === be misleading in boolean checks?
Question 47
What is a pitfall when checking for NaN using equality?
Question 48
How can double negation lead to bugs when used in return statements?
Question 49
Why can mixing || and ?? without parentheses cause syntax errors?
Question 50
What is a safe strategy when writing complex boolean expressions?
