JavaScript

setIntervalでforeach

More than 5 years have passed since last update.


function loop(array, callback, interval){
var i = array.length;
timerID = setInterval(function(){
if(!i) {
clearInterval(timerID);
return;
}
callback(array[array.length-i]);
i--;
}, interval);
}

DEMO

http://jsdo.it/_shimizu/oaXj