Lets say we have one array with a number of objects in it. Each object has defined properties:
arr1 = [
{name: "Harry", lastname: "Potter"},
{name: "Charlie", lastname: "Brown"},
{name: "Frodo", lastname: "Baggins"}
]
We have a second array with an additional properties for the objects in arr1. The objects in arr2 are in the same order as arr1:
arr2 = [
{bestfriend: "Ron"},
{bestfriend: "Snoopy"},
{bestfriend: "Sam"}
]
Is there any way to insert the properties of objects in arr2 to arr1?
The expected result is
arr1 = [
{name: "Harry", lastname: "Potter", bestfriend: "Ron"},
{name: "Charlie", lastname: "Brown", bestfriend: "Snoopy"},
{name: "Frodo", lastname: "Baggins", bestfriend: "Sam"}
]