for in the for of a difference?

? for in the for of a difference
let arr = [1,2,3,4,5,6];

for(let i in arr){
	console.log(i);
}
for(let j of arr){
	console.log(j);
}

for in 中的循环变量代表的是下标(key)
for of 中的循环变量代表的是元素(value)

Guess you like

Origin blog.csdn.net/weixin_45052104/article/details/90927218