Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

lodash
communitycreator
javascript
html

What is the _.pullAll() method in Lodash?

Shubham Singh Kshatriya

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The _.pullAll() method in Lodash removes all the specified values from an array.

This is very similar to the _.pull() method. The only difference is that it accepts an array of values rather than comma-separated values.

Syntax

_.pullAll(array, values)
_.pullAll() syntax

Parameters

This method accepts the following parameters:

  • array: This is the array to be modified.
  • values: This is an array of values that are to be removed from the array.

Return value

This method mutates the original array and returns it.

Example

Console
Implementation of the _.pullAll() method

Explanation

In the "HTML" tab:

  • Line 5: We import the lodash script.

In the "JavaScript" tab:

  • Line 2: We create the numbers array and populate it with a few values.
  • Line 5: We use the _.pullAll() method to remove the specified values.
  • Line 8: We print the numbers on the console.

Output

In the output, we see the original array from which the specified values are removed by the _.pullAll() method.

RELATED TAGS

lodash
communitycreator
javascript
html

CONTRIBUTOR

Shubham Singh Kshatriya

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring