let arr =[1,2,3,4]

for(let i in arr){console.log(i)}
 0
 1
 2
 3

for(let i of arr){console.log(i)}
 1
 2
 3
 4

let obj={a:1,v:2}

for(let i in obj){console.log(i)}
 a
 v

for(let i of obj){console.log(i)}  //报错 obj is not iterable

  看完大概就能明白了吧!

posted on 2019-09-02 15:25  白不了的黑发  阅读(201)  评论(0编辑  收藏  举报