1let list = [4, 5, 6];
2
3for (let i in list) {
4 console.log(i); // "0", "1", "2",
5}
6
7for (let i of list) {
8 console.log(i); // "4", "5", "6"
9}
10
11// EXAMPLE 2
12let pets = new Set(["Cat", "Dog", "Hamster"]);
13pets["species"] = "mammals";
14
15for (let pet in pets) {
16 console.log(pet); // "species"
17}
18
19for (let pet of pets) {
20 console.log(pet); // "Cat", "Dog", "Hamster"
21}
1const array = ['hello', 'world', 'of', 'Corona'];
2
3for (const item of array) {
4 console.log(item);
5}
1for (let step = 0; step < 5; step++) {
2 // Runs 5 times, with values of step 0 through 4.
3 console.log('Walking east one step');
4}
5
1const array1 = ['a', 'b', 'c'];
2
3for (const element of array1) {
4 console.log(element);
5}
6
7// expected output: "a"
8// expected output: "b"
9// expected output: "c"
10
1const array1 = ['a', 'b', 'c'];
2
3for (const element of array1) {
4 console.log(element);
5}
1let arr = ['el1', 'el2', 'el3'];
2
3arr.addedProp = 'arrProp';
4
5// elKey are the property keys
6for (let elKey in arr) {
7 console.log(elKey);
8}
9
10// elValue are the property values
11for (let elValue of arr) {
12 console.log(elValue)
13}