VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-pull-method/

⇱ Lodash _.pull() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.pull() Method

Last Updated : 2 Sep, 2024

Lodash _.pull() method is used to remove all the given values from a given array.

Syntax:

_.pull(array, [values]);

Parameters:

  • Array: This parameter holds the query array.
  • values: This parameter holds one or multiple elements that need to be removed from the array.

Return Value:

  • It returns an array that contains the remaining element.

Example 1: In this example, the lodash _.pull method removes all the values from an array that match with given values.

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.

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.

Output:

[ 'a', 'b', 'd' ]

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

Comment