for var in list javascript code example
Example 1: for elem in list javascript
var myList = ["first element", "second element", "third element"];
for (let elem in myList) {
console.log(elem);
}
Example 2: for item loop
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"