while loop a condition is tested and if it evaluates to true only then, the control enters the loop and the block of code will get executed. After that, again the condition will be tested and if it again evaluates to true then again the code will be executed. This block will continue to execute as long as the condition is true. If at any time it evaluates to false, the loop execution will stop.
Here is the another example of While Loop
infinite loop, is a loop that will keep running forever i.e. the condition specified in this loop will
never evaluate to false. It can crash the browser or can hang the computer. People should be aware when writing
the code that they shouldn't accidentally create an infinite loop.
Example- If there is
'i=2', and in while loop the condition is
'i>1', and inside the loop there
is an increment in the value of
'i', then it will create an infinite loop as the value of 'i' will always be
greater than '1' and hence the condition will be true always.
Note: If the updated content is not visible to you please refresh the cookies by pressing CTRL + Shift + R.