Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@theabbie that wouldn’t (shouldn’t) actually work in a browser, however, as it leads browsers to stop JS execution on page. A much better alternative (that actually works) is: ’for (;;) {}’
-
@100110111 It does stop the current page, also, both infinite loops are equivalent. Crashing the browser will be difficult using any JS code, playing large media file might help in crashing.
-
@theabbie infinite for loop is pretty standard (at least I see it quite a bit in C and Java code that I’ve worked with, and I know it’s possible in JS, tho never had a reason to use it). Tbh I can’t think of a reason why somebody should use any infinite loop in front-end JS, but the infinite for loop shouldn’t crash your page just by the virtue of being there. Whatever the case, you’ll want some way of breaking out of the loop...
-
bad-frog5464yhow bout setting a variable to True,
then checking the loop against that variable?
maybe browsers arent smart enough to identify it as an infinite loop ?
and if they are, maybe setting said variable to 1, incrementing it up, if statement to prevent overflow and while loop waiting for it to be 0 might do the trick?
How to make a endless loop program in JavaScript?
question