I have a code like this :
array = [...]; //very long array
processArray = function(array) {
let result =[];
let Nindex=0;
let process = function (){
// process array (long function) and create result array
if (Nindex++ < array.length-1) {
setTimeout(process, 1) //Call recursion
}
}
process(); // start processing
return result
}
resultingArray = processArray (array);
How can I make the function wait all the recursions before returning result ?