Last Updated : 15 Jul, 2025
Lodash_.pullAllWith() method is similar to the _.pullAll() method that returns the first array containing the values that are in the first array not in the second array but in _.pullAllWith() all the elements of the first array are compared with the second array by applying comparison provided in third. It may be a little complex to understand by reading this but it will become simple when you see the example.
Syntax:_.pullAllWith(array, values, [comparator]);Parameters:
Example 1: In this example, we are removing the giving array from another array that has the same value as it and printing the result in the console.
JavaScript
// Requiring the lodash library
const _ = require("lodash");
// Original array
let x = [1, 2, 3]
// Value array to be subtracted
let y = [2, 4, 5]
// Printing the original array
console.log("Before : ", x);
// Array after _.pullAllWith()
// method where _.isEqual is the
// comparator
_.pullAllWith(x, y, _.isEqual);
// Printing the output
console.log("After : ", x);
Output:
Example 2: In this example, we are removing the giving array from another array that has the same value as it and printing the result in the console.
JavaScript
// Requiring the lodash library
const _ = require("lodash");
// Original array
let x = [{ a: 1 }, { b: 2 }, 6]
// Value array to be subtracted
let y = [{ a: 1 }, 7, 6]
// Printing the original array
console.log("Before : ", x);
// Array after _.pullAllWith()
// method where _.isEqual is the
// comparator
_.pullAllWith(x, y, _.isEqual);
// Printing the output
console.log("After : ", x);
Output:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4