whatstheoutput_

#15: !![]

Topic: coercion · Difficulty: ★

console.log(!![]);

Output

true

Why

JavaScript's truthiness rules only mark seven values falsy: false, 0, -0, 0n, '', null, undefined, and NaN. Every object — including an empty array — is truthy, because objects are never on that list; only their contents or string form matter for coercions like +, not for boolean context. The first ! flips the truthy array to false, and the second ! flips it back to true, which is why !!value is the standard idiom for converting anything to an explicit boolean.

More coercion puzzles

Play today's puzzle →