Student-friendly HTML, CSS, and JavaScript reference with examples
5 === "5" // false
Comparisons don’t calculate a new value — they answer a yes/no question, and always give
back a boolean.
5 > 3 // true
5 < 3 // false
5 >= 5 // true
5 <= 3 // false
5 === 5 // true
5 === "5" // false — same value, different type
5 !== "5" // true — "not equal" is the opposite of ===
=== checks the value and the type. A number is never equal to the text version of
the same number.
"b" > "a" // true — alphabetical order
"apple" === "apple" // true
==5 == "5" // true — == ignores the type
5 === "5" // false — === doesn't
== quietly converts one side to match the other before comparing, which is almost never
what you want. Always use === and !==.