The difference between ==
and ===
is that the former one checks values only (1 == "1"
will return true) whether the latter one checks the values and additionally checks types (1 === "1"
will return false since number
is not string).
Comparing objects means comparing object references (object variable holds internal addresses to the objects they refer to and those addresses are being compared). If two objects have totally the same keys and values, functions, etc. but they are separate objects, ==
will return false so ===
will also return false.
The question is: does it make any difference if I use ==
or ===
comparison operator concerning JavaScript objects? PS if I'm wrong anywhere, please correct me and explain (and I'll accept it as the question answer)
edit: this is NOT about javascript primitives, so comparing objects and primitives is off-topic.