Looking to merge two JavaScript object arrays similar to a vlookup function in Excel. The goal is to match objects from one array with another, and then combine them into a single array for streamlined access.
For instance,
let array1 = [
{"first":"Ana","last":"Anderson","id":"0001"},
{"first":"Bob","last":"Brown","id":"0002"},
{"first":"Charlie","last":"Clark","id":"0003"},
{"first":"Danielle","last":"Dunn","id":"0004"}
]
let array2 = [
{"age":"38","id":"0002","eyeColor":"hazel","hieght":"5.5"},
{"age":"45","id":"0001","eyeColor":"brown","hieght":"5"},
{"age":"23","id":"0003","eyeColor":"blue","hieght":"6"}
]
How can I create an array that merges the data like this?
let array3 = [
{"first":"Ana","last":"Anderson","id":"0001","age":"45","eyeColor":"brown","height":"5"},
{"first":"Bob","last":"Brown","id":"0002","age":"38","eyeColor":"hazel","height":"5.5"},
{"first":"Charlie","last":"Clark","id":"0003","age":"23","eyeColor":"blue","height":"6"},
{"first":"Danielle","last":"Dunn","id":"0004","age":"","eyeColor":"","height":""}
]