JavaScript Loops Flashcards
What is the purpose of a loop?
It is used typically for running code a number of times
What is the purpose of a condition expression in a loop?
It acts as a counter to how many times a loop is run
What does ‘iteration’ mean in the context of loops?
It is similar to how many times a loop has run
When does the initialization expression of a while loop get evaluated?
At the start of the loop
When does the initialization expression of a for loop get evaluated?
At the start of the loop
When does the condition expression of a for loop get evaluated?
After the initialization and then at the start of every following loop
When does the final expression of a for loop get evaluated?
After the code block and before the start of the loop
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
A break statement
What does the ++ increment operator do?
It increases the count by one for whatever it is attached to
How do you iterate through the keys of an object?
Using a for…in loop