Categories
JavaScript Answers

How to remove array element based on object property with JavaScript?

Spread the love

To remove array element based on object property with JavaScript, we use the filter method.

For instance, we write

const newArray = myArray.filter((obj) => {
  return obj.field !== "money";
});

to call myArray.filter with a callback that return an array with objects that has the field property not equal to 'money'.

By John Au-Yeung

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

Leave a Reply

Your email address will not be published.