Forum Discussion

khanh_tran's avatar
khanh_tran
New Contributor III
5 years ago
Solved

How to merge all objects in an array

I got an array named “group” includes object items as the below picture How can I merge all object items to one object? My expected result as the below picture. But, imagine that the number of...
  • j_angelevski's avatar
    5 years ago

    That won’t be a problem here, because I’m using destructuring assignment ( the three dots ) before the $group array ...$group, this will always work for every $group array regardless of the array size, you don’t have to get each index from the $group array, just use ...$group, this will destructure the array and will be the same as writing $group[0]... $group[n] multiple times.