To merge 2 arrays of JavaScript objects, we use the spread operator.
For instance, we write
const arr1 = [
{ name: "lang", value: "German" },
{ name: "age", value: "18" },
];
const arr2 = [
{ name: "childs", value: "5" },
{ name: "lang", value: "German" },
];
const arr3 = [...arr1, ...arr2];
to use the spread operator to spread the arr1
and arr2
entries into a new array and assign the array to arr3
.