For-in statement
For-in statements allow a certain piece of code to be executed repeatedly for each element in an array.
The for-in statement starts with the for
keyword, followed by the name of the element that is used in each iteration of the loop, followed by the in
keyword, and then followed by the array that is being iterated through in the loop.
Then, the code that should be repeatedly executed in each iteration of the loop is enclosed in curly braces.
If there are no elements in the data structure, the code in the loop will not be executed at all. Otherwise, the code will execute as many times as there are elements in the array.
Last updated