for of loop js object code example
Example 1: loop in object javascript
var person = {"name":"Rasel", age:26};
for (var property in person) {
console.log(person[property]);
}
Example 2: javascipr for of
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
// expected output: "a"
// expected output: "b"
// expected output: "c"
Example 3: for in and for of in js
const iterable = [10, 20, 30];
for (const value of iterable) {
console.log("fef"+value);
}
// 10
// 20
// 30