Categories
JavaScript Answers

How to remove an element from a list, with JavaScript Lodash?

Spread the love

To remove an element from a list, with JavaScript Lodash, we use the remove method.

For instance, we write

_.remove(subTopics, (currentObject) => {
  return currentObject.subTopicId === stToDelete;
});

to call remove to remove the item in the subTopics array that has the subTopicID equals stToDelete by calling it with the callback that returns the condition.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *