Documentation

Student-friendly HTML, CSS, and JavaScript reference with examples

Sections

Comparison Operators

5 === "5" // false

Comparisons don’t calculate a new value — they answer a yes/no question, and always give
back a boolean.

Greater Than, Less Than

5 > 3    // true
5 < 3    // false
5 >= 5   // true
5 <= 3   // false

Equality

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.

Strings Compare Too

"b" > "a"    // true — alphabetical order
"apple" === "apple"    // true

Warning: Never Use ==

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 !==.