Less than or equal (<=)

The less than or equal (<=) operator returns true if the left operand is less than or equal to the right operand, and false otherwise.

Try it

Syntax

x <= y

Description

The operands are compared using the same algorithm as the Less than operator, except that equal values (after attempting coercion) return true.

Examples

String to string comparison

"a" <= "b"; // true
"a" <= "a"; // true
"a" <= "3"; // false

String to number comparison

"5" <= 3; // false
"3" <= 3; // true
"3" <= 5; // true

"hello" <= 5; // false
5 <= "hello"; // false

Number to Number comparison

5 <= 3; // false
3 <= 3; // true
3 <= 5; // true

Number to BigInt comparison

5n <= 3; // false
3 <= 3n; // true
3 <= 5n; // true

Comparing Boolean, null, undefined, NaN

true <= false; // false
true <= true; // true
false <= true; // true

true <= 0; // false
true <= 1; // true

null <= 0; // true
1 <= null; // false

undefined <= 3; // false
3 <= undefined; // false

3 <= NaN; // false
NaN <= 3; // false

Specifications

Specification
ECMAScript Language Specification
# sec-relational-operators

Browser compatibility

BCD tables only load in the browser

See also