Lodash _.pullAll() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Like _.pull, but accepts an array of values to remove. Uses SameValueZero equality. Returns the same array (mutated). Part of Lodash 4.x Array (since 4.0.0).

Warning: Unlike _.difference, this method mutates array. Prefer _.pull for a few separate arguments; use pullAll when the ban list is already an array.

Syntax

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

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

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

Library declarations
Lodash
_.pullAll(array, values)

Parameters

ParameterDescription
arrayRequired. Array to mutate
valuesRequired. Array of values to remove

Return Value

Return ValueDescription
*Same array reference

Lodash Examples

Example 1 — Official: Pull an Array of Values

Remove every "a" and "c" listed in a ban array.

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

_.pullAll(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. Ban list. Pass ["a","c"] as one array argument.
  3. All matches go. Both as and both cs are removed.
  4. Mutates. The variable array now holds ["b","b"].

Example 2 — Single Value in the Ban List

A one-item values array still removes every occurrence.

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

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

How It Works

  1. Ban list. Only "a" is listed.
  2. Both gone. First and fourth slots are removed.
  3. Order kept. Remaining items stay in relative order.
  4. Same as pull. Equivalent to _.pull(array, "a").

Example 3 — No Matching Values

If nothing in the ban list matches, the array stays the same.

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

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

How It Works

  1. Ban list. 9 and 10 are not in the source.
  2. No removals. Length and contents stay the same.
  3. Empty ban. _.pullAll(arr, []) also leaves arr unchanged.
  4. Safe. Missing values do not throw.

Example 4 — Pull NaN via Ban List

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

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

_.pullAll(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 — pullAll vs pull

Same result — different argument shape.

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

_.pullAll(a, ban);       // → ["b"]
_.pull(b, "a", "c");     // → ["b"]

// Prefer pullAll when ban is already an array
Try It Yourself

How It Works

  1. Same ban. Both remove a and c.
  2. pullAll. Takes ban as one array.
  3. pull. Needs each value as its own argument (or a spread).
  4. Choose. Config lists → pullAll; a few literals → pull.

Browser & Runtime Support

_.pullAll is a Lodash 4.x Array helper (since 4.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

_.pullAll()

Available in [email protected] full builds and the lodash/pullAll modular import. There is no single native twin — closest patterns are a mutating filter loop or arr.filter / _.difference 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
_.pullAll Lodash 4.x+

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

Frequently Asked Questions

_.pullAll(array, values) removes every occurrence of each value listed in the values array from array in place, using SameValueZero equality. It returns the same array reference.
Yes. Unlike _.difference, pullAll changes the array you pass in. Clone first (for example with slice) if you need to keep the old contents.
pull takes individual values as separate arguments. pullAll takes one array argument listing every value to remove — ideal when the ban list is already an array.
_.difference returns a new array and leaves the source alone. _.pullAll mutates the source and returns that same array.
No. Listing "a" twice does not change the result — each distinct value is still removed everywhere it appears.
Use import pullAll from "lodash/pullAll" or require("lodash/pullAll") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.pullAll.

Next: _.pullAllBy()

Remove values matched through an iteratee (property path or function).

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