how to create new array based on the two different arrays with same id in Typescript/JavaScript?
let array1 = [
{
invoiceId: 1,
name:'Ajay',
contact:'0001'
},
{
invoiceId: 2,
name:'vijay',
contact:'1234'
},
{
invoiceId: 3,
name:'Amit',
contact:'4581'
},
];
let array2 = [
{
invoiceId: 1,
age:24,
email:'[email protected]'
},
{
invoiceId: 2,
age:23,
email:'[email protected]'
},
];
in both array the common field is invoice id based on invoiceid have to create new array as example give below.
let expectedresult = [
{
name:'Ajay',
age:24
},
{
name:'vijay',
age:23
},
{
name:'Amit',
age:null
},
];
how to handle this in Typescript/JavaScript. is there any solution based on Lodash?
reactjstag if the question has nothing to do with ReactJS.