Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How to join two arrays of objects into one with JavaScript

const a = [{id: 1}, {id: 2}];
const b = [{id: 3}, {id: 4}];
// expected result: [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
const result = a.concat(b);
console.log(result);
// outputs: [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
Source by iaforek.medium.com #
 
PREVIOUS NEXT
Tagged: #How #join #arrays #objects #JavaScript
ADD COMMENT
Topic
Name
8+8 =