Skip to content
Advertisement

Javascript arrays of Objects; Subtract one from another

Put simply, I want to subtract one array from another.

The arrays are arrays of objects. I understand I can cycle through one array and on each item, comparing values in the other array, but that just seems a little messy.

Thanks for the help, hopefully this question isnt too basic, I have tried googling it with no luck 🙁

EDIT:

The Objects in the Arrays I wish to remove will have identical values but are NOT the same object (thanks @patrick dw). I am looking to completely remove the subset from the initial array.

Advertisement

Answer

http://phpjs.org/functions/index

There is no built-in method to do this in JavaScript. If you look at this site there are a lot of functions for arrays with similar syntax to PHP.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement