javascript for of
const array = ['hello', 'world', 'of', 'Corona']; for (const item of array) { console.log(item); }
for loop in javascript
const numbers = [3, 4, 8, 9, 2]; for (let i = 0; i < numbers.length; i++) { const accessNumbers = numbers[i]; console.log(accessNumbers); } //Expected output:3 4 8 9 2
for loop in javacript
//first type for(let i; i< number; i++){ //do stuff //you can break break } //2nd type const colors = ["red","green","blue","primary colors"] colors.forEach((color) =>{ //do stuff //But you can't breack out of the loop }) //3rd type might not be considered as a loop colors.map((color) =>{//do stuff //no bracking})
What is a for loop in javascript
for( initialization of expression; condition; action for initialized expression ) { instruction statement to be executed; }
Source: www.freecodecamp.org