This is normal if there is a break statement inside the loop.
If there is no break statement, the JavaScript runtime will continue to execute the code in a loop over and over, with the "i" growing, growing and growing. Soon, "i" will become more than anything; more than the number of legos that a rich child you knew at school, even in your playroom. This will go past being a number greater than the number of ants in the world, then the number of Starbucks, and then the number of water molecules in the ocean. At some point, the browser may ask if you want it to stop the script, but if you are wondering if you are the kind of person who likes to explore the unknown, then you will decline the offer and let it go. Soon the value of āiā will reach truly astronomical values, and everything will become interesting. Remember how in 2001 A Space Odyssey all became weird when the dude got involved in Jupiter or something else? It may be so.
Try jsfiddle.
Pointy
source share