A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/lodash-_-pullall-method/ below:

Lodash _.pullAll() Method - GeeksforGeeks

Lodash _.pullAll() Method

Last Updated : 02 Sep, 2024

Lodash _.pullAll() method is used to remove all the values from the first given array that are given in the second array.

Syntax:
_.pullAll(array, values);
Parameters: Return Value:

Example 1: In this example, it removes the second array of elements from the first array and returns the remaining elements.

javascript
const _ = require('lodash');

let ar = [1, 2, 3, 4, 5]
let rem = [1, 3]
let value = _.pullAll(ar, rem)

console.log(value)

Output:

[ 2, 4, 5 ]

Example 2: In this example, it removes the second array of elements from the first array and returns the remaining elements.

javascript
const _ = require('lodash');

let ar = [1, 2, 3, 1, 3, 4, 1, 5]
let rem = [1, 4, 5]
let value = _.pullAll(ar, rem)

console.log(value)

Output:

[ 2, 3, 3 ]

Example 3: In this example, it removes the second array elements from the first array and returns the remaining elements.

javascript
const _ = require('lodash');

let ar = ['a', 'b', 'c', 'd']
let rem = ['b', 'c']
let value = _.pullAll(ar, rem)

console.log(value)

Output:

[ 'a', 'd' ]

Note: This will not work in normal JavaScript because it requires the library lodash to be installed.



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