$( document ).ready(function() {
var someFn = function()
{
console.log( (new Date) );
};
var i = 0;
var max = 10;
var _interval = setInterval(function() {
if( i < max )
{
someFn();
i++;
} else {
clearInterval( _interval );
}
}, 1000);
});
function callByTimeouts(handler, timeouts) {
var startTime = Date.now();
var currentIndex = 0;
var timer = setInterval(function () {
var currentTime = Date.now();
var nextCallTime = startTime + timeouts[currentIndex];
if (currentTime < nextCallTime) return;
handler();
var nextIndex = currentIndex + 1;
if (nextIndex < timeouts.length) {
currentIndex = nextIndex;
} else {
clearInterval(timer);
}
}, 100);
}
callByTimeouts(function () {
console.log('qwerty');
}, [1000, 2500, 7500]);