虽互不曾谋面,但希望能和您成为笔尖下的朋友
以读书,技术,生活为主,偶尔撒点鸡汤
不作,不敷衍,意在真诚吐露,用心分享
点击左上方,可关注本刊
标星公众号(ID:itclanCoder)
如果不知道如何操作
点击这里,标星不迷路
比较下for..of 与 for..in 的区别
请写出如下代码的结果
var arr = ['a', 'b', 'c'];
Array.prototype.hello = 'd';
for(item of arr) {
console.log(item);
}
for(item in arr) {
console.log(item);
}
答案: 输出 a
,b
,c
, 0
,1
,2
,hello
共同点: 都会遍历数组的属性
不同点