js中for in,of区别

let x;
let a = ['a','b','c']
let b = {name:'LIUNAN',age:19}
for(x of a){
document.write(x)
}
for(x in a){
document.writeln(x+':'+a[x])
}

for(x in b){
console.log(x+":"+b[x])
}
</script>

posted @ 2018-04-23 22:21  江山一族  阅读(806)  评论(0编辑  收藏  举报