Favorites

JavaScript < Less than Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
<
JavaScript Comparison OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

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 < y

Example

console.log(2 < 10);
console.log('2' < '10');
console.log(new Date(2025, 0) < new Date(2026, 0));

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.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee