Skip to main content

lte()

lte(value, other): boolean

Checks if value is less than or equal to other.

DEPRECATED

Use the <= operator directly instead.


Parametersโ€‹

value: numberโ€‹

The value to compare.

other: numberโ€‹

The other value to compare.


Returns: booleanโ€‹

true if value is less than or equal to other, else false.


See Alsoโ€‹

Less than or equal (<=) - MDN


Sinceโ€‹

2.0.0


Also known asโ€‹

lte (Lodash, Ramda) ยท โŒ (es-toolkit, Remeda, Radashi, Effect, Modern Dash, Antfu)


Exampleโ€‹

// โŒ Deprecated approach
lte(1, 3); // => true
lte(3, 3); // => true
lte(3, 1); // => false

// โœ… Recommended approach
1 <= 3; // => true
3 <= 3; // => true
3 <= 1; // => false

How it works?โ€‹

Checks if value is less than or equal to other. Deprecated: Use <= operator directly.

Native Equivalentโ€‹

// โŒ lte(a, b)
// โœ… a <= b

Use Casesโ€‹

Compare less or equal ๐Ÿ“Œโ€‹

Check if first value is less than or equal to second.

a <= b;

Validate maximumโ€‹

Check maximum constraints.

if (quantity <= maxQuantity) {
processOrder(quantity);
}