I want to know how to merge two arrays of objects into a single array using javascript
var arr1 = [ {编号:1, name: "xxx"} ] var arr2 =[ {详细信息:“财务”, 费用:“100”} ] Tried. var result1 = [...arr1, ...arr2]; var result=Object.assign({}, ...result1)
Expected output [ { Number: 1, Name: "xxx", Details: "Finance", Cost: "100" } ]
P粉9550636622024-04-06 09:21:57
var arr1 = [ {id:1, name: "xxx"} ] var arr2 =[ {details:"finance", cost:"100"} ] const result = arr1.map((item, index) => ({ ...item, ...arr2[index] })) console.log(result)