JavaScript <= Less than or equal Operator
The less than or equal operator (<=) checks whether the left value is smaller than or equal to the right one.
Description
The less than or equal operator <= returns true if the left operand is smaller than or equal to the right. A common use is in loop conditions.
Like the other relational operators, it converts strings and objects before comparing, and null is treated as 0, which explains the odd-looking result that null <= 0 is true while null == 0 is false. Any comparison with NaN returns false.
In loops, choosing between < and <= decides whether the end value is included. Off-by-one errors often come from using <= with an array length; for arrays, loop with i < arr.length because the last index is one less than the length.
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





