0

How can one write an infinite loop?

6th Jun 2020, 12:48 PM
Hisoka
Hisoka - avatar
4 Antworten
+ 3
Writing this kind of infinite loop in javascript is a very bad idea: the web page where your script reside will not respond anymore (and the browser/app running it could freeze, depending on how is implemented the page display ^^)... If you need to execute some code infinitively, you must consider the use of setTimeout, setInterval or the modern requestAnimationFrame global functions to let time to the page/browser to handle display refresh and user interactions: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals
6th Jun 2020, 1:32 PM
visph
visph - avatar
+ 2
while(true) or for(;;).
6th Jun 2020, 1:13 PM
HonFu
HonFu - avatar
+ 1
Write a condition that remains true always Like 1 == 1
6th Jun 2020, 12:56 PM
Hardik Sharma
Hardik Sharma - avatar