Get Unique Object Data From two array of objects in Javascript

var olddata= [
    { name:“string 1”, value:“this”, other: “that” },
{ name:“string 2”, value:“this”, other: “that” }
];

var newdata = [
{ name:“string 1”, value:“this”, other: “that” },
{ name:“string 5”, value:“this”, other: “that” },
{ name:“string 4”, value:“this”, other: “that” }
];

newdata.forEach((items, index)=>{

if( olddata.findIndex(item => item.name === items.name) == –1){

console.log(‘index’,items);

}

})

Leave a Comment

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