0
let existing_array  = [
    {name: "a",  age: 15},
    {name: "b",  age: 16},
    {name: "c",  age: 17},
    {name: "d",  age: 18}
    {name: "e",  age: 19}];

now I have a new array

let new_array =  = [
    {name: "f",  age: 15},
    {name: "b",  age: 16},
    {name: "g",  age: 17},
    {name: "h",  age: 18}
    {name: "i",  age: 19}];

now both existing_array and new_arrray has the name value 'b' and I want it to be removeed from the new array

0

1 Answer 1

1

Use filter() in combination with find:

new_array = new_array.filter(x => !existing_array.find(y => x.age === y.age && x.name === y.age))

You may want to use a better equality check.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.