The comparison operator (==) in JavaScript is not transitive. Translating from the mathematical, this means that the fact that a == b and a == cdoes not imply that b == c .
A simple example:
var a = ""; var b = new String(a); var c = new String(a);
What's the matter? The fact is that the variables b and c are objects (and different), and a is a primitive value (a string literal). Two object variables are considered unequal if they refer to different objects. When comparing a primitive value and an object, other rules are used - everything is reduced to strings and then compared. ')
What is it fraught with? It is fraught with very subtle mistakes. From the programmer's point of view, the primitive value of the string type and the object created from the string by the String () constructor are almost indistinguishable, and even in many books this moment is mentioned in passing, without concrete examples.
The situation is similar with other primitive types and corresponding objects, for example, Number.