CKTIS / JavaScript
Less-than operator (<)
The < operator checks whether its left operand is smaller than its right operand. It compares numbers or strings, may perform type conversions, and returns true or false when it completes normally.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
left < rightleft < right is a strict ordering comparison: if the values being compared after any required conversions are equal, the result is false. Normal completion produces a Boolean, but conversion can throw an exception. Operand expressions are evaluated from left to right; objects are then converted to primitive values with a number hint, also from left to right. This conversion can execute user code. Even x < x can return true if x is an object whose valueOf method returns 1 on the first call and 2 on the second.
If both resulting values are strings, comparison is lexicographic by UTF-16 code units, not by natural-language sorting rules. Thus, "12" < "3" is true. Otherwise, numeric conversion rules apply: "12" < 3 is false. Number and BigInt can be compared, including when the Number has a fractional part.
If the operation reaches the numeric comparison and either value is NaN, the operator returns false. This includes values converted to NaN, such as undefined. Consequently, !(a < b) is not generally equivalent to a >= b. Numeric conversion of a Symbol throws a TypeError before the numeric comparison, so NaN < Symbol() throws rather than returning false. Comparing a BigInt with a string that cannot be converted to a BigInt produces false rather than throwing.
Do not write a range as 0 < x < 10: it is interpreted as (0 < x) < 10, so the second comparison receives a Boolean. Use 0 < x && x < 10.
Examples
console.log(3 < 5);
console.log(5 < 5);
console.log("12" < "3");
console.log("12" < 3);
console.log(NaN < 5);
console.log(2n < 2.5);Result
true false true false false true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.