Yes, setInterval(timeout, 1000)it does almost the same thing. This is somewhat different in that the next interval starts counting right after 1000 ms, and not after the script that runs (or even starts) is executed. I am opposed to this precisely for this reason, for most purposes. Your implementation is better, IMO.
In addition, you do not need to pass the function timeoutto a string, you can just pass the link directly, i.e. setTimeout(timeout, 1000)instead of setTimeout("timeout()", 1000).
source
share