Answers for "how to replace object with other object in array javascript"

-1

javascript find object in array and replace it

const updatedData = originalData.map(x => (x.id === id ? { ...x, updatedField: 1 } : x));
Posted by: Guest on December-11-2020
0

update array of object using other array javascript

arra1 = arra1.map(item => {
  let item2 = arra2.find(i2 => i2.transid === item.transid);
  return item2 ? { ...item, ...item2 } : item;
});
Posted by: Guest on October-14-2021

Code answers related to "how to replace object with other object in array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language