0
white screen on the right and no looped write cycles
hi everyone! please tell me why when I'm making "While" cycle as neverending (condition 3 was removed) nothing happens? we have return command "Write", so system should write X values without stopping, but system just hanging my browser every time )) I just want to see lots of continuosly written X values, but I see just white screen at the right side, and that is not correct the logic is: x=0 while x < 1 write x, so why X was not written on the screen? this should be done by the system before returning to the while section.. right?
4 ответов
+ 11
Put some delay......
+ 11
setInterval(callback,milliseconds);
+ 10
while can only hold one parameter like while (x < 5)
+ 2
Infinite or never ending loops will definitely crash your browser. Even humans tend to go crazy when they sit in one spot and try to crack a problem till eternity (I hope you get the analogy).
Because your loop runs forever, the browser keeps trying to evaluate your code, 'forgetting' to perform other tasks it needs to. This is why it appears to be freezing. If you need your code to run infinitely, use a timer with a small amount of delay. Of course you'd run into timing issues, but that is if you would mind.