16 == [16] → true // Array converted into string, then into number 16 == [1,6] → false // But what is array converted into? "1,6" == [1,6] → true
The Top 10 Things Wrong with JavaScript
Richard Kenneth Eng
11123

For these double equals comparisons it’s trying to convert both sides to a string.

(16).toString() → “16”

[16].toString() → “16”

[1,6].toString() → “1,6”

Show your support

Clapping shows how much you appreciated Billy McKee’s story.