Concat several arrays in JavaScript (nodejs) -
what more concise way concat ar arrays in following object:
var obj = { field1: { ar: [...] }, field2: { ar: [...] }, ... fieldn: { ar: [...] } }
i found this:
object.keys(obj).reduce(function(array, entry) { return array.concat(obj[entry].files); }, []);
you may try this:
[].concat.apply([], [array1, array2, ...])
Comments
Post a Comment