js的数组
数组循环
最简单的循环
let a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for (let i = 0; i < a.length; i++) {
console.log(a[i]);
}
for of循环.
这个和forEach一样,只能得到值
for (const iterator of a) {
console.log(iterator);
}
forEach方法循环
只能得到值
a.forEach((v) => {
console.log(v);
});

浙公网安备 33010602011771号