Many designs using a for or while loop structure may instead have needed the setTimeout() method of the window object calling a function recursively. The general form of this structure is:
function MyFunc() {
//code here
timeoutID = setTimeout("MyFunc()", 1000)
}
where timeoutID is a script-global variable. After MyFunc() is called, this structure then recursively calls MyFunc() every second until clearTimeout(timeoutID) is used. Unlike a for or while loop, this "loop" is time based.