+ 1
What is the process of the for loop?
<script> for (i=0;i<5;i++){ i+=i; document.write(i); i++; } </script>
1 ответ
+ 2
Understand it step-by-step :
When i=0, gets in the loop
i+=i means i+=0 - > i=0
prints 0
i++ - > i=1
i++ again from the increment of the for loop, i=2, gets in the loop
i+=2 - > i=4
prints 4
i++ - > i=5
Again i++ from the increment statement in for loop, i=6
Now i>=5 hence loop will break.