Skip to main content

lt()

lt(value, other): boolean

Checks if value is less than 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 other, else false.


See Also​

Less than (<) - MDN


Since​

2.0.0


Also known as​

lt (Lodash, Ramda) · ❌ (es-toolkit, Remeda, Radashi, Effect, Modern Dash, Antfu)


Example​

// ❌ Deprecated approach
lt(1, 3); // => true
lt(3, 3); // => false
lt(3, 1); // => false

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

How it works?​

Checks if value is less than other. Deprecated: Use < operator directly.

Native Equivalent​

// ❌ lt(a, b)
// βœ… a < b

Use Cases​

Compare less than πŸ“Œβ€‹

Check if first value is less than second.

a < b;

Check limit​

Validate value is under limit.

if (items.length < maxItems) {
items.push(newItem);
}