I have two object arrays. One is main array and another one is temp array. I need to compare main array with temp array and based on matching id, I have update the value in the main array from temp array.
For example, id 2 & 3 is matching in both the arrays. So I need to update value in the main array from temp array.
// Main array
this.MyArray = [
{ id: "0", value: "Car" },
{ id: "1", value: "Bike" },
{ id: "2", value: "Train" },
{ id: "3", value: "Bus" },
{ id: "4", value: "Van" }
]
// temp array
this.tempArray =[
{ id: "2", value: "Car" },
{ id: "3", value: "Jet" },
]
//Expected Output in the Main array:
this.MyArray = [
{ id: "0", value: "Car" },
{ id: "1", value: "Bike" },
{ id: "2", value: "Car" },
{ id: "3", value: "Jet" },
{ id: "4", value: "Van" }
]