for of javascript example
Example 1: javascript for of
const array = ['hello', 'world', 'of', 'Corona'];
for (const item of array) {
console.log(item);
}
Example 2: for in loop javascript
var person = {"name":"taylor","age":31};
for (property in person) {
console.log(property,person[property]);
}
Example 3: for of loop javascript
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
Example 4: for of loop syntax javascript
for (let step = 0; step < 5; step++) {
console.log('Walking east one step');
}
Example 5: javascript for of
const numbers = [1,2,3,4];
for(const item of numbers){
console.log(item);
}
Example 6: Iterate with JavaScript For Loops
var myArray = [];
for (var i = 1; i <= 5; i++){
myArray.push(i);
}
console.log(myArray)