I wanted to know how I can merge two arrays
of objects *(putting one inside another would also work for me).*
For example:
array["nombre": "paco", "edad": "21"];
array2["nombre": "matias", "edad": "25"];
it would look like this:
arraydefinitivo[array, array2]
I've tried with push
, but it doesn't work for me.
You can use concant to join 2 arrays
Other alternative
[].concat(array1, array2, array3);
Now if you want to concatenate discriminating by some condition, for example only concatenate the even numbers of 2 arrays
The problem is in the declaration of an array of objects. The correct way would be:
Then you use concat to join both:
The complete example would be: