I have nested Array (arrays in parent array).
let myArray = [ [], [ 8300, 8400, 8500, 8600 ], [ 6379 ], [ 5672 ], [ 27017 ] ]
I am trying to mix all of this into one array .
let targetArray = [8300, 8400, 8500, 8600, ..., 27017]
I used reduce and concat to achieve this goal.
let unique_array = myArray.map(p=>{p}).reduce((prev, next)=>{prev && prev.concat(next))
but I am getting this error:
Uncaught Error TypeError: Reduce of empty array with no initial value
so my question is how can I skip this error?