Lodash _.pull() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Removes all given values from array using SameValueZero equality. Returns the same array (mutated). Part of Lodash 4.x Array (since 2.0.0).

Warning: Unlike _.without, this method mutates array. Use _.pullAll when values live in an array argument.

Syntax

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

Lodash
_.pull(array, [values])
CallWhat it does
_.pull(array, [values])Primary signature.
_.pull(array)Call with an array argument.

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

Library declarations
Lodash
_.pull(array, [values])

Parameters

ParameterDescription
arrayRequired. Array to mutate
valuesOptional. Variadic values to remove

Return Value

Return ValueDescription
*Same array reference

Lodash Examples

Example 1 — Official: Pull Multiple Values

Remove every "a" and "c" in place.

Lodash
var array = ["a", "b", "c", "a", "b", "c"];

_.pull(array, "a", "c");
// → ["b", "b"]
// array is also ["b", "b"]
Try It Yourself

How It Works

  1. Source. Six letters with duplicates of a, b, and c.
  2. Targets. Pass "a" and "c" as separate arguments.
  3. All matches go. Both as and both cs are removed.
  4. Mutates. The variable array now holds ["b","b"].

Example 2 — Pull a Single Value

One value argument still removes every occurrence.

Lodash
var array = ["a", "b", "c", "a", "b", "c"];

_.pull(array, "a");
// → ["b", "c", "b", "c"]
Try It Yourself

How It Works

  1. One target. Only "a" is listed.
  2. Both gone. First and fourth slots are removed.
  3. Order kept. Remaining items stay in relative order.
  4. Tip. Not “remove first match only” — every match is pulled.

Example 3 — No Matching Values

If nothing matches, the array stays the same (still the same reference).

Lodash
var array = [1, 2, 3, 1, 2, 3];

_.pull(array, 9);
// → [1, 2, 3, 1, 2, 3]
Try It Yourself

How It Works

  1. Ask for 9. No element equals 9.
  2. No removals. Length and contents stay the same.
  3. Still mutates API-wise. You get the same array object back.
  4. Safe. Missing values do not throw.

Example 4 — Pull NaN

SameValueZero lets NaN match NaN (unlike plain ===).

Lodash
var array = [NaN, 1, NaN, 2];

_.pull(array, NaN);
// → [1, 2]
Try It Yourself

How It Works

  1. Trap with ===. NaN === NaN is false.
  2. SameValueZero. Lodash still treats both NaNs as matches.
  3. Result. Both NaN slots are removed.
  4. Also. +0 and -0 count as equal for removal.

Example 5 — pull vs without

Immutable alternative: _.without returns a new array.

Lodash
var source = ["a", "b", "c", "a"];

var kept = _.without(source, "a");
// kept → ["b", "c"]
// source still ["a", "b", "c", "a"]

_.pull(source, "a");
// source → ["b", "c"]
Try It Yourself

How It Works

  1. without first. Builds a new array; source is untouched.
  2. pull next. Mutates source by removing "a"s.
  3. Choose. Prefer without when shared state must stay intact.
  4. Docs note. Official Lodash docs call out this difference explicitly.

Browser & Runtime Support

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

✓ Stable · Lodash 4.x

_.pull()

Available in [email protected] full builds and the lodash/pull modular import. There is no single native twin — closest patterns are a mutating filter loop or arr.filter for a new array.

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
_.pull Lodash 4.x+

Bottom line: Safe for production once Lodash is loaded. Prefer import pull from "lodash/pull" for smaller bundles. Remember: this helper mutates — pair with without when you need immutability.

Frequently Asked Questions

_.pull(array, ...values) removes every occurrence of the given values from array in place, using SameValueZero equality. It returns the same array reference.
Yes. Unlike _.without, pull changes the array you pass in. Clone first (for example with slice) if you need to keep the old contents.
_.without returns a new array and leaves the source alone. _.pull mutates the source and returns that same array.
pull takes individual values as separate arguments. pullAll takes one array listing every value to remove.
No. Every element that equals any given value is removed — duplicates are all stripped.
Use import pull from "lodash/pull" or require("lodash/pull") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.pull.

Next: _.pullAll()

Remove every value listed in another array, still in place.

_.pullAll() 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