Loops (Repeated Code Execution)
What are control structures
Loops how often some code is executed
Loops
Arrays
For loop n number of times
For...of Loops through all elements of an array
Objects
For...in Loop through all properties in an object
While Loops as long as a certain condition met
The regular loop
The "for-of" Loop (FOR ARRAYS)
Years ago, we didn't have the for-of-loop in JavaScript.
To still loop through all the elements of an array, this code could be used:
for (let i = 0; i < someArray.length; i++) {
console.log(someArray[i]);
}
This code still works today and you can absolutely use it instead of using a for-of loop. But of course, it's longer and a bit more clunky, so there is no strong reason to use that code unless you prefer it.








Comments
Post a Comment