how to use for in javascript code example
Example 1: javascript for loop
var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Example 2: javascript for loop
var i;
for (i = 0; i < 10 ; i++) {
}
Example 3: for in loop javascript
var person = {"name":"taylor","age":31};
for (property in person) {
console.log(property,person[property]);
}
Example 4: for of loop javascript
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
Example 5: loop javascript
var speed = 100;
setInterval(function() {
},speed);
Example 6: javascript loop
let array = ["foo", "bar"]
let low = 0;
let high = array.length;
for(let i = low; i < high; i++) {
console.log(i);
console.log(array[i]);
}