JavaScript’s abstract equality might sound quite daunting… until you realise that pretty much every operator and function in JavaScript has the same problem. After all why does JavaScript’s equality and ordering works the way it does?
The direct answer is “coercion polymorphism”[^1]. But since this is unlikely to tell you anything useful, unless you have implemented either JavaScript or similarly polymorphic languages in the past, let’s go in a short journey of how JavaScript operators work, with a particular focus on the idea of equality.