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 

Console Dev tools 

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.

For in loop  (for Objects)


While

For of 

for in 








Comments

Popular posts from this blog

Arrays JavaScript Objects JavaScript

ADVANCE FUNCTIONS JS