Last Updated : 02 Sep, 2024
Lodash _.pull() method is used to remove all the given values from a given array.
Syntax:_.pull(array, [values]);Parameters:
Example 1: In this example, the lodash _.pull method removes all the values from an array that match with given values.
javascript
const _ = require('lodash');
let ar = [1, 2, 3, 4, 5]
let value = _.pull(ar, 3, 5)
console.log(value)
Output:
[ 1, 2, 4 ]
Example 2: In this example, the lodash _.pull method removes all the values from an array that match with given values.
javascript
const _ = require('lodash');
let ar = [1, 2, 3, 1, 3, 4, 1, 5]
let value = _.pull(ar, 1, 5)
console.log(value)
Output:
[ 2, 3, 3, 4 ]
Example 3: In this example, the lodash _.pull method removes all the values from an array that match with given values.
javascript
const _ = require('lodash');
let ar = ['a', 'b', 'c', 'd']
let value = _.pull(ar, 'c')
console.log(value)
Output:
[ 'a', 'b', 'd' ]
Note: It 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