var arr = [[1,2,3],[[4],[5,[6,7],[8,9]],10]]; function fn(b) { var a = [].concat.apply([], b); return b.length != a.length ? fn(a) : a }; alert(JSON.stringify(fn(arr)));