I have an array which contains arrays too. this array is template
template
has 2 arrays, but 2 is not fixed, it can go on N number of arrays which also contains arrays.
this is what I tried:
const template = health_pack_templates.map((healthpackItem, i) => {
return healthpackItem.health_pack_templates
});
console.log('template', template);
var c = [];
for (var i = 0; i >= template.length; i++) {
c.push.apply(template[i]);
}
console.log('c',c)
c
does only returns []
and not an array with 0,1,2,3,4,5,6,7,8,9 arrays inside. What am I doing wrong?
what I want to happen should be like this: [array 0,1,2,3,4,5,6,7,8,9] after it is merged.
Try using flat()
method
The flat() method which creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With