+ 6
Infinite function in JavaScript
How to run a function in JavaScript forever?
5 Answers
+ 16
setInterval(func,millis);
+ 5
Thanks
+ 4
but how to...I' m new to JavaScript
+ 4
This a basic loop : var i=0;
while (i<=10) {
document.write(i + "<br />");
i++;
}
The i++ means that the variable i increase, and i increae from 0 to reach 10 in this loop. You can change the value of i, and to make this loop infinite, you can just remove the i++ (increament). So if i=1, the function will write 1 infinite of times on each lines, but this kind of loop can crash your browser if you run the loop on it, or it will just doesn't work to prevent a crash. I hope my answer helpful for you, and have fun with loops :D
+ 2
Use an infinite loop (recursive or iterative)