Why does “true” == true show false in JavaScript?

Because "true" is converted to NaN, while true is converted to 1. So they differ.

Like you reported, both are converted to numbers, because at least true can be (see Erik Reppen’s comment), and then compared.

Leave a Comment