Lodash _.dropWhile() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Creates a slice of array excluding elements dropped from the beginning. Elements are dropped until predicate returns falsey. Part of Lodash Array since 3.0.0 (stable in 4.x — not deprecated).

Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.

Syntax

Call _.dropWhile on an array. Start with this line.

Lodash
_.dropWhile(array, [predicate=_.identity])
CallWhat it does
_.dropWhile(array, [predicate=_.identity])Primary signature.
_.dropWhile(array)Call with an array argument.

Prefer import dropWhile from "lodash/dropWhile" when you want a smaller bundle.

Library declarations
Lodash
_.dropWhile(array, [predicate=_.identity])

Parameters

ParameterDescription
arrayRequired. Source to trim from the start
predicateOptional. Invoked as (value, index, array); default _.identity

Return Value

Return ValueDescription
*New array without the matching leading prefix

Lodash Examples

Example 1 — Official: Function Predicate

Drop leading inactive users until the first active one.

Lodash
var users = [
  { user: "barney",  active: false },
  { user: "fred",    active: false },
  { user: "pebbles", active: true }
];

_.dropWhile(users, function (o) { return !o.active; });
// → [{ user: "pebbles", active: true }]
Try It Yourself

How It Works

  1. Source. Three users; first two are inactive.
  2. Predicate. !o.active is truthy for inactive users.
  3. Drop prefix. barney and fred are removed.
  4. Stop. pebbles is active → predicate falsy → keep the rest.

Example 2 — Official: Matches Object

Drop while the element deeply matches a partial object.

Lodash
var users = [
  { user: "barney",  active: false },
  { user: "fred",    active: false },
  { user: "pebbles", active: true }
];

_.dropWhile(users, { user: "barney", active: false });
// → [{ user: "fred", active: false }, { user: "pebbles", active: true }]
Try It Yourself

How It Works

  1. Shorthand. An object uses Lodash _.matches iteratee rules.
  2. First item. barney matches → dropped.
  3. Second item. fred does not match → stop.
  4. Result. fred and pebbles remain in order.

Example 3 — Official: MatchesProperty Pair

Drop while active === false using a [path, value] pair.

Lodash
var users = [
  { user: "barney",  active: false },
  { user: "fred",    active: false },
  { user: "pebbles", active: true }
];

_.dropWhile(users, ["active", false]);
// → [{ user: "pebbles", active: true }]
Try It Yourself

How It Works

  1. Pair form. ["active", false] means “property equals value”.
  2. Drop. Both inactive users match and are removed.
  3. Stop. pebbles.active is true → not equal → stop.
  4. Keep. Only the active user remains.

Example 4 — Official: Property Shorthand

A string tests truthiness of that property — falsy stops immediately.

Lodash
var users = [
  { user: "barney",  active: false },
  { user: "fred",    active: false },
  { user: "pebbles", active: true }
];

_.dropWhile(users, "active");
// → all three users (nothing dropped)
Try It Yourself

How It Works

  1. Property iteratee. "active" reads each object’s active field.
  2. First value. barney.active is false (falsy).
  3. Stop at once. Falsy ends the drop — no items removed.
  4. Tip. Use this when leading items are truthy and you want to skip that run.

Example 5 — Leading Zeros

Only the contiguous leading run is removed; a later zero stays.

Lodash
_.dropWhile([0, 0, 1, 2, 0], function (x) {
  return x === 0;
});
// → [1, 2, 0]
Try It Yourself

How It Works

  1. Leading run. First two values equal 0 → dropped.
  2. Break. 1 fails x === 0 → stop.
  3. Suffix kept. [1, 2, 0] — the trailing zero is not removed.
  4. Rule. Unlike filter, later matches after the break stay put.

Browser & Runtime Support

_.dropWhile is a Lodash 4.x Array helper (since 3.0.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.0.0+

_.dropWhile()

Available in [email protected] full builds and the lodash/dropWhile modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.dropWhile Lodash 3.0.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import dropWhile from "lodash/dropWhile" for smaller builds. Not a native browser API — load Lodash first.

Frequently Asked Questions

_.dropWhile(array, predicate) walks from the start and drops elements while the predicate returns a truthy value. At the first falsy result it stops and returns a new array from that index onward.
No. It returns a new array slice. The source array is left unchanged. Object elements inside are still shared by reference.
filter can remove matches anywhere in the array. dropWhile only removes a contiguous prefix from the beginning — once the predicate fails, every later element is kept, even if it would match again.
You get an empty array. If the first element already fails the predicate, you get a shallow copy of the whole array.
Use import dropWhile from "lodash/dropWhile" or require("lodash/dropWhile") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.dropWhile.
Same as other Lodash iteratees: a function, a matches object, a matchesProperty pair like ["active", false], or a property name string. Default predicate is _.identity.

Next: _.fill()

Fill array elements with a value from start to end indexes.

_.fill() tutorial →

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.

10 people found this page helpful