I’m trying to compare the differences between similar snippets with javascript and C++. Here’s my snippet:
var i = 0;
while (i<=10)
{
document.write('Hello<br />');
//i++;
}
With C++, if I write an equivalent snippet, I recall the console prints that line forever until I enter Ctrl + C. However, with Javascript, if I try to open the browser, it would crash. Does it have to do with the browser trying to load that “Hello” line forever until I force quit?
You can’t stop the process in javascript like you can do in C++.
In javascript most browsers even have a limit of the number of loop execution and most browsers (if not all) will crash with those type of loops.
Just no infinite looping in JS