Rasi
answered Nov 30 '-1 00:00
setInterval is function in JavaScript which call per interval .
syntax ::
setInterval (function(){},intervalTimeInMiliSecond)
setInterval have two argument , first is function to call per interval and second argument is time interval which in millisecond.
setTimeout is function in JavaScript which call once after given time .
syntax ::
setTimeout (function(){},timeoutMiliSecond)
setTimeout have two argument . first is function to call after timeout . second argument is time in millisecond which is time need to pass before call first argument function.
big difference between is one run per interval . it will remain on until we make clearInterval , and setTimeout is run once when given time passed
setInterval for repeat action for given interval and setTimeout is one time action after given time
setTimeout mostly used to execute function after some delay. it used to buffer delay before run function.
setInterval is means n time of running setTimeout for given time passed.
so we can say this
var sEtInterval=function(func,interval){
setTimeout(func,interval);
sEtInterval(func,interval);
}
setInterval is like recursion of setTimeout for n time until it interrupted
in above sEtInterval(alert('me'),1200)=setInterval(alert('me'),1200)