1for (var i; i < 10; i++) {
2
3}
1let str = "";
2
3for (let i = 0; i < 9; i++) {
4 str = str + i;
5}
6
7console.log(str);
8// expected output: "012345678"
9
1const myArray = ['foo', 'bar'];
2
3myArray.forEach(x => console.log(x));
4
5//or
6
7for(let i = 0; i < myArray.length; i++) {
8 console.log(myArray[i]);
9}
10
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}
1//for ... of statement
2
3const array1 = ['a', 'b', 'c'];
4
5for (const element of array1) {
6 console.log(element);
7}
8
9// expected output: "a"
10// expected output: "b"
11// expected output: "c"
12
1const array1 = ['a', 'b', 'c'];
2
3for (const element of array1) {
4 console.log(element);
5}