HTML and CSS Reference
In-Depth Information
You can check whether something is
smaller or larger than another thing:
Returns
true
if the first
value is less than the
second value
<
LESS
THAN
Returns
true
if the first
value is greater than the
second value
>
GREATER
THAN
When you compare strings with < and >,
JavaScript takes the numeric value of the
characters and compares them. This means
H
is greater than
C
, but
H
is less than
c
,
because lowercase letters are all larger
than uppercase letters for comparison pur-
poses. As with the arithmetic operations
you saw earlier, bugs can occur if you're
expecting to compare numbers but in real-
ity are comparing strings. JavaScript
doesn't complain in either case.
You can also compare smaller and larger
and equal to:
<=
LESS THAN OR
EQUAL TO
Returns
true
if the
first value is less
than or equal to the
second value
>=
GREATER THAN
OR EQUAL TO
Returns
true
if the
first value is greater
than or equal to the
second value