Skip to content

Instantly share code, notes, and snippets.

View manatax's full-sized avatar

Zeke manatax

  • Los Angeles
View GitHub Profile
@manatax
manatax / flatten.js
Last active May 29, 2017 22:19
flatten an array of arbitrarily nested arrays
let data = [[1,2,[3]],4];
function flatten(array) {
let res = [];
for (let item of array) {
if (Array.isArray(item)) {
res = res.concat(flatten(item));
} else {
res.push(item);
}