What's the best way to merge 2 disparate data sets in javascript? For example,
const parentRecords = [{
id: 1,
mycol1: 'parent name',
}]
const childRecords = [{
childid: 2,
parentId: 1,
mycol2: 'child name',
}]
const mergedRecords = [...parentRecords, ...childRecords]
This code returns an array where each of the records above exist as separate rows. I need the result to look like this:
[{
id: 1,
mycol1: 'parent name',
childid: 2,
parentId: 1,
mycol2: 'child name',
}]