标签:
能工摹形,巧匠窃意。 -- 毕加索
let nicknames = [‘di‘, ‘boo‘, ‘punkeye‘];
nicknames.size = 3;
for (let nickname of nicknames) {
console.log(nickname);
}
Result: di, boo, punkeye
for...in 用来遍历对象中的属性:
let nicknames = [‘di‘, ‘boo‘, ‘punkeye‘];
nicknames.size = 3;
for (let nickname in nicknames) {
console.log(nickname);
}
Result: 0, 1, 2, size
对比方可以看到这一微弱的变化 所引发的美感!
let nicknames = [‘di‘, ‘boo‘, ‘punkeye‘];
nicknames.size = 3;
for (let nickname of nicknames) {
console.log(nickname);
}
Result: di, boo, punkeye
for...in 用来遍历对象中的属性:
let nicknames = [‘di‘, ‘boo‘, ‘punkeye‘];
nicknames.size = 3;
for (let nickname in nicknames) {
console.log(nicknames[nickname]);
}
Result:di, boo, punkeye 3
标签:
原文地址:http://www.cnblogs.com/zxyun/p/5842637.html