Less-than Operator
In JavaScript, Less-than comparison operator takes two operands, returns true if value in left side operand is less than that of the right operand, or false otherwise.
Syntax
<
symbol is used for less-than operator.
a < 5 //returns true if a has a value < 5
a < b //returns true if a has a value < b
Examples
1. Check if value in a
is less than 5
.
var a = 3;
if (a < 5) {
console.log('a is less than 5');
} else {
console.log('a is not less than 5');
}
2. Check if value in a
is less than that of in b
.
var a = 9;
var b = 4;
if (a < b) {
console.log('a is less than b');
} else {
console.log('a is not less than b');
}