Types of loops:
Regular for loop
for(let i=0; i<array.length; i++){}
For each loop
array.forEach(cut=>{console.log(cut);});
//can’t use break or continue over forEach
For in loop
for(const item in array){console.log(item);}
//iterates over added prototype functions too
for of (Does not work on objects)
for (const item of array){console.log(item);}
//does not iterate over added prototypes
//break and continue works too
//works on nodelists
No comments:
Post a Comment