Why does [] == ![] evaluate to true?
Quick answer
![] is false → []==false → []==0 → '' ==0 → 0==0 → true.
In detail
Step by step: `![]` is false (an array is truthy, negated). Now `[] == false`; booleans coerce to numbers so `false` → 0, giving `[] == 0`. The array coerces to a primitive '' (empty string), so `'' == 0`; the string coerces to 0, giving `0 == 0` → true. A perfect illustration of why `==` is dangerous.
[] == ![];
// ![] -> false
// [] == false-> [] == 0
// '' == 0 -> 0 == 0
// => trueWhy interviewers ask this: A notorious trick question to test coercion mastery.
This is 1 of 118+ questions in the JavaScript Interview Kit
Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.
⚡ Get the JavaScript Interview Kit → ₹299