Repeating setTimeout

Maybe you should use setInterval()


setInterval() is probably what you're looking for, but if you want to do get the same effect with setTimeout():

function doSomething() {
    console.log("10 seconds");
    setTimeout(doSomething, 10000);
}

setTimeout(doSomething, 10000);

Or if you don't want to declare a separate function and want to stick with a function expression you need to make it a named function expression:

setTimeout(function doSomething() {
    console.log("10 seconds");
    setTimeout(doSomething, 10000);
}, 10000);

(Or use arguments.callee if you don't mind using deprecated language features.)


according to me setInterval() is the best way in your case.
here is some code :

 setInterval(function() {

//your code

}, 10000); 
// you can change your delay by changing this value "10000".