Flatten an Array of Arrays

You can use reduce() and append() to flatten and array of arrays.

Here’s an example:

a = [[1,2,3],[4,5,6],[7,8,9]]; b = a.reduce(function(a,b){a.append(b)},[]) // b -> [1,2,3,4,5,6,7,8,9]

 

Copyright Picolabs | Licensed under Creative Commons.