javascript loop for in code example
Example 1: javascript for
let str = "";
for (let i = 0; i < 9; i++) {
str = str + i;
}
console.log(str);
Example 2: javascript for of
const array = ['hello', 'world', 'of', 'Corona'];
for (const item of array) {
console.log(item);
}
Example 3: for in loop javascript
var person = {"name":"taylor","age":31};
for (property in person) {
console.log(property,person[property]);
}
Example 4: forin js
let panier = ['fraise', 'banane', 'poire'];
for (const fruit in panier) {
console.log(panier[fruit]);
}
Example 5: for in javascript
const object = { a: 1, b: 2, c: 3 };
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}