setTimeout is the functionality which comes along with the webapi whereas setInterval is javascript implementation.
setTimeout(expression, timeout); runs the code/function once after the timeout.
The clearTimeout() method stops the execution of the function specified in setTimeout().
function doStuff() { alert("run your code here when time interval is reached"); } var myTimer = setTimeout(doStuff, 5000);
Output
run your code here when time interval is reached
setInterval(expression, timeout); runs the code/function in intervals, with the length of the timeout between them.
function doStuff() { alert("run your code here when time interval is reached"); } var myTimer = setInterval(doStuff, 5000);
Output
run your code here when time interval is reached