do while loops
do { console.log('Hello'); }
while (false)
console.log('Goodbye');
How does this statement print out 'Goodbye'? Where in the code does it value to false?
The loop starts with "do" and ends with "while". It's a "do...while" loop, not an ordinary "while" loop.
So the part the prints out "Goodbye" comes after and outside the loop, and will always be done.
Ah I get it! console.log('Goodbye'); is not in curly braces in which I was picturing that's how it was set up to be which would then be dependent on the while loop. Further, do while loops syntax just ends in "while()".
Comments
Post a Comment