JavaScript < Less than Operator
The less than operator (<) checks whether the left value is smaller than the right one.
Description
The less than operator < returns true if the left operand is smaller. Like the other relational operators, it compares strings by character codes and other mixed types numerically. Dates can be compared directly because they convert to timestamps.
When both operands are strings, they're compared character by character using UTF-16 code units, so upper-case letters sort before lower-case ones and 'Zebra' < 'apple' is true. Use localeCompare() for natural alphabetical order. Comparisons involving NaN or undefined are always false.
The < character also starts HTML tags, so if you write JavaScript inside an HTML attribute or an inline <script> that's processed as XHTML, it may need escaping. In normal script files and <script> elements, it needs no special treatment.
Properties
- Operator
<- Category
- Comparison
- Precedence
- 9 (1 is lowest, 18 is highest)
- Associativity
- left-to-right
Syntax
x < yExample
Browser Support
The following information will show you the current browser support for the < operator. Hover over a browser icon to see the version that first introduced support for this operator.
Desktop





Tablets & Mobile





