for let i in array javascript code 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 array javascript
let iterable = [10, 20, 30];
for (let value of iterable) {
value += 1;
console.log(value);
}
Example 4: for in javascript
for (let i = start; i < end; i++) {
}
Example 5: use these instead of a for loop javascript
const array = [1, 2, 3];array.forEach(function(elem, index, array) { array[index] = elem * 2;});console.log(array);
Example 6: how to use for of in javascript
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}