JavaScript-ループ2-

2023-04-04

for in, for of

const ary = [1,2,3,4,5];

for in は添え字(index)
for (let i in ary) {
console.log(ary[i]);
}

for of は値(value)
for(let v of ary) {
console.log(ary[v]);
}

日記

Posted by シキ