A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/en-US/docs/Web/JavaScript/Reference/Operators/Less_than_or_equal below:

Less than or equal (<=) - JavaScript

Less than or equal (<=)

Baseline Widely available

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
console.log(5 <= 3);
// Expected output: false

console.log(3 <= 3);
// Expected output: true

// Compare bigint to number
console.log(3n <= 5);
// Expected output: true

console.log("aa" <= "ab");
// Expected output: true
Syntax Description

The operands are compared using the same algorithm as the Less than operator, with the operands swapped and the result negated. x <= y is generally equivalent to !(y < x), except for two cases where x <= y and x > y are both false:

In addition, x <= y coerces x to a primitive before y, while y < x coerces y to a primitive before x. Because coercion may have side effects, the order of the operands may matter.

x <= y is generally equivalent to x < y || x == y, except for a few cases:

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 Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4