JSFiddle - React, Tailwind, and code Playground
JavaScript
var array = [1, 2, 3, 4, 5, [1, 3, 2, [1, 3, 2, 4, 1], 0, 1, 0]];
function alisar(arr) {
var novo = [];
function redutor(arr, el) {
if (Array.isArray(arr)) {
while ((el = arr.pop()) || arr.length) redutor(el);
} else {
novo.push(arr);
}
}
redutor(arr);
return novo.reverse();
}
console.log(alisar(array));