As far as I can tell, these two pieces of javascript behave the same way:
Option A:
function myTimeoutFunction()
{
doStuff();
In my opinion the simplest difference between setTimeout(expression,duration) and setInterval(expression,duration) is that:-
setTimeout() will execute the expression only once in the specified duration.
However, setInterval() will execute the specified expression again and again with each execution being delayed(time gap between two consecutive execution) by the specified duration.