What happens if we accidentally create an endless loop?


#1


Hey guys! I just started with loops and am wondering what I can do in the event that I accidentally create an endless loop thus causing my browser to crash? What would be the way to "break" the code from running? 

Asking just in case this happens to me... and also out of curiosity, I guess! Thanks! 



#2

Read an article like
https://stackoverflow.com/questions/43922400/how-do-an-infinite-loop-in-javascript
found with goole-search
javascript what happens if we create an endless loop site:stackoverflow.com


#3

Our code should run, do its work, and then stop until it’s triggered to run again. With an infinite loop, there is no breakpoint, nothing to stop the code from running. So it just keeps on running…over and over again…looping until the browser crashes.

If you accidentally create an infinite loop, you need to close the tab or browser. How?

Depending upon the browser you’re using, some have a timeout feature. When it times out, a popup appears and lets you stop the unresponsive script.

If on Windows, you can open the task manager and then stop the browser’s process. On Mac, you can Force Quit an application (click on the Apple icon in the top left hand corner and select Force Quit).

If those don’t work for you, do a Google search. Here’s one I found on Stack Overflow.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.