Father of Samwise

Equality

In JavaScript, the == operator tests value, but the === operator tests value as well as type.

So, the strict comparison operators compare type as well as value. I'm not sure why that's useful. Clearly, if I'm checking to see if two things are the same in a real-world example, the number 9 on which I can perform calculations is not the same as the character 9 with which I can't do math. Wouldn't I always want type to be treated as an element of value if I'm comparing two variables?

$("#a").html(9 == "9" ? "true" : "false");
$("#b").html(9 == 9 ? "true" : "false");
$("#c").html(9 === "9" ? "true" : "false");
$("#d").html(9 === 9 ? "true" : "false");