How to simply flatten array in jQuery? I have:
[1, 2, [3, 4], [5, 6], 7]
And I want:
[1, 2, 3, 4, 5, 6, 7]
Old question, I know, but...
I found this works, and is fast:
function flatten (arr) { b = Array.prototype.concat.apply([], arr); if (b.length != arr.length) { b = flatten(b); }; return b; }