I have a result from Q.all()
which is something like this -
promise = [Arr1,Arr2,Arr3....]
Each Arr
can be either null
or an array of plain JS objects.
I want to join all these arrays to one big array;
I can loop over and use array concat
method to join them.
Is there any other elegant solution which is inbuilt in JS ?
Here is sample array -
[
{
"endDate": "2015-06-11 14:52:00",
"quantity": 75,
},
{
"endDate": "2015-06-11 14:42:00",
"quantity": 78,
},
{
"endDate": "2015-06-01 14:43:00",
"quantity": 69,
},
{
"endDate": "2015-05-14 13:38:00",
"quantity": 85,
}
]
I have these libraries available as well
lodash
,angular
I believe that would be a combination of
flattenDeep
(to do the flattening) andwithout
(to removenull
s — at least, I think you wanted to removenull
s; if not, takewithout
out):Live Example: