Lodash _.lte() method

Beginner
⏱️ 5 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.lte(value, other) mirrors _.lt but includes equality.
  • Why string-vs-string skips number coercion (lexicographic <=).
  • How dates compare cleanly thanks to Number(date) → timestamp.
  • Common range-check and inventory patterns (with the fixed direction).

Prerequisites

You finished the _.lt tutorial; the rules below are the same, only the equal-to branch flips.

  • You understand JavaScript’s <= operator and basic coercion.
  • Try-it labs load lodash from the CDN.

Overview

Lodash builds _.lte through the same relational-operation helper as _.lt: string pair → lexicographic <=, otherwise both arguments are coerced via Number(...). The only behavioral difference is that equal values return true.

Includes equality

_.lte(3, 3)true; the “edge inclusive” flavor of _.lt.

Date-friendly

Number(date) = timestamp, so deadlines and timestamps compare correctly.

NaN-aware

undefinedNaNfalse. Even _.lte(NaN, NaN) is false.

Syntax

javascript
_.lte(value, other)
  • value: the first value to compare.
  • other: the second value to compare against.
  • Returns: true if value is less than or equal to other; otherwise false.
1

Number comparison basics

The lodash docs trio — note that the middle case flips from _.lt.

javascript
import lte from "lodash/lte";

console.log(
  "1 <= 3: " + lte(1, 3) + "\n" +    // true  (lodash docs)
  "3 <= 3: " + lte(3, 3) + "\n" +    // true  (lodash docs — differs from _.lt)
  "3 <= 1: " + lte(3, 1)              // false (lodash docs)
);
Try it Yourself
2

Inventory check (edge-inclusive)

Use _.lte to fulfil an order when the request fits within stock—equal counts still pass.

javascript
import lte from "lodash/lte";

const inStock = 100;

function canFulfill(requested) {
  return lte(requested, inStock);
}

console.log(
  "request 60:  " + canFulfill(60) + "\n" +   // true
  "request 100: " + canFulfill(100) + "\n" +  // true (edge inclusive)
  "request 120: " + canFulfill(120)            // false
);
Try it Yourself
3

Strings, dates, and nullish

Same coercion rules as _.lt: two strings stay strings, dates become timestamps, null becomes 0, undefined becomes NaN.

javascript
import lte from "lodash/lte";

const today = new Date("2026-05-12");
const deadline = new Date("2026-05-12");

console.log(
  "'apple' <= 'apple': " + lte("apple", "apple") + "\n" +  // true
  "'10' <= '9':        " + lte("10", "9") + "\n" +              // true (lexicographic)
  "today <= deadline:  " + lte(today, deadline) + "\n" +              // true (same timestamp)
  "null <= 0:          " + lte(null, 0) + "\n" +                       // true (Number(null) = 0)
  "undefined <= 1:     " + lte(undefined, 1)                            // false (NaN)
);
Try it Yourself

📋 _.lte vs related operators

API / patternBehavior
_.lte(a, b)Includes equality (<=); string pair → lexicographic, otherwise number coercion.
_.lt(a, b)Strict less-than; equal values return false.
_.gte(a, b)Mirror of _.lte—greater than or equal.
a <= bNative operator; equivalent for primitives but never branches on string-pair detection.

Pitfalls to avoid

Logic

Mind the argument order

A common bug: writing _.lte(available, requested) when you meant _.lte(requested, available). Re-read the call as “A is <= B” before shipping.

Strings

Digit strings sort lexicographically

_.lte('10', '9') is true. For numeric order, convert with Number(...) first.

BigInt

BigInt throws

Lodash routes through Number(...), which can’t convert BigInt. Use the native <= operator for arbitrary-precision integers.

❓ FAQ

_.lte() returns true on equality. _.lt(3, 3) is false; _.lte(3, 3) is true. Otherwise the coercion rules are identical.
Yes—Number(date) returns the millisecond timestamp, so _.lte(new Date('2020-01-01'), new Date('2020-01-01')) is true and earlier-or-equal dates return true.
When both args are strings, lodash uses string <=. Compared character by character, '1' is less than '9', so '10' sorts before '9'.
Yes: `_.lte(min, x) && _.lte(x, max)` keeps both endpoints inclusive. The native equivalent is `min <= x && x <= max`.

Summary

  • Purpose: return true when value <= other with predictable coercion.
  • Remember: only the equality branch differs from _.lt—great for inclusive ranges, deadlines, capacity limits.
  • Next: see the Lodash _.toArray() index for _.toArray and friends.
Did you know?

_.lte is the only relational helper in lodash where a === b returns true_.lt, _.gt, and the strict </> operators all return false for equal values. That single bit of difference is why the inventory or deadline pattern (“include the edge”) reaches for _.lte.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful