Skip to content

Instantly share code, notes, and snippets.

@tqg5
tqg5 / flatten.js
Created March 2, 2017 22:41
Flatten Array
var arr = [[1,2,[3,4,[5,6]]],[4,10,23,[3,5,[56]]]];
function flattenArr(val) {
if(val instanceof Array) {
return val.reduce(function(acc, val) {
return acc.concat(flattenArr(val));
},[]);
}