Why [] == ![] Is True in JavaScript: The Type Conversion Rules Explained
A developer's late-night puzzle over the expression [] == ![] being true is broken down step by step. The article explains that ! turns an empty array into false, and that the loose == operator then converts types before comparing. Each conversion, from array to string to number, is traced to show the result follows fixed rules rather than randomness. The author contrasts this with the strict === operator, which skips conversion entirely, and shares a personal lesson about wasting time chasing a bug that did not exist. The piece closes by reassuring beginners that these quirks follow a learnable rulebook.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in