function loopFunction(delay, callback){ var loop = function(){ callback(); setTimeout(loop, delay); }; loop(); }; loopFunction(1000, function(){console.log('Hello World!')});