js for x in array code example
Example 1: for in javascript
const object = {a: 1, b: 2, c: 3};
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}
// expected output:
// "a: 1"
// "b: 2"
// "c: 3"
Example 2: how to use for of in javascript
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}