HTML and CSS Reference
Comparing Numbers. When the comparison operators are used to compare num-
bers, numeric values are compared; as in, is 50 > 45 ? A Boolean value of either true or
false is returned.
Table 5.9 Comparison Operators
How Operator Compares Numbers
x > y
x is greater than y
x >= y
x is greater than or equal to y
x < y
x is less than y
x <= y
x is less than or equal to y
var x = 5;
var y = 4;
var result = x > y;
document.writeln("The result is "+ result + ".<br />");
result = x < y;
document.writeln( "The result is " + result + ".<br />");
The variables x and y are assigned values to be compared later in the program.
If the value of x is greater than the value of y , a Boolean value of either true or false
is returned and assigned to the variable result .
The Boolean result of the comparison is displayed by the browser. It is true ; x is
greater than y .