Вы можете использовать Синтаксис распространения :
const data1 = [{ name: 'abc', age: 26, title: 'xyz', address: { street: 'yyy', city: 'ttt', country: 'kkk' } }]
const date2 = [{ color: 'blue', sqad: 'jkl', priority: 'rst', division: 'opq', range: 456 }]
const result = [{...data1[0], ...date2[0]}]
console.log(result)
.as-console-wrapper { max-height: 100% !important; top: 0; }
Если у вас есть n
объекты в date1
и date2
, вы можете получить result
, используя Синтаксис Spread вместес Array.prototype.map ()
const data1 = [{ name: 'abc', age: 26, title: 'xyz', address: { street: 'yyy', city: 'ttt', country: 'kkk' } }, { name: 'def', age: 26, title: 'xyz', address: { street: 'yyy', city: 'ttt', country: 'kkk' } }]
const date2 = [{ color: 'blue', sqad: 'jkl', priority: 'rst', division: 'opq', range: 456 }, { color: 'green', sqad: 'jkl', priority: 'rst', division: 'opq', range: 456 }]
const result = data1.map((d, i) => ({...data1[i], ...date2[i]}))
console.log(result)
.as-console-wrapper { max-height: 100% !important; top: 0; }