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]
var a = [1, 2, [3, 4], [5, [6, [7, 8]]]]; var b = []; function flatten(e,b){ if(typeof e.length != "undefined") { for (var i=0;i
The flatten function should do it, and this doesn't require jQuery. Just copy all of this into Firebug and run it.