1 let arr = ["Apple", "Orange", "Pear"]; 2 3 for (let i = 0; i < arr.length; i++) { 4 alert( arr[i] ); 5 }
for循环方式
1 let fruits = ["Apple", "Orange", "Plum"]; 2 3 // 遍历数组元素 4 for (let fruit of fruits) { 5 alert( fruit ); 6 }
for..of方式
1 let arr = ["Apple", "Orange", "Pear"]; 2 3 for (let i = 0; i < arr.length; i++) { 4 alert( arr[i] ); 5 }
for循环方式
1 let fruits = ["Apple", "Orange", "Plum"]; 2 3 // 遍历数组元素 4 for (let fruit of fruits) { 5 alert( fruit ); 6 }
for..of方式