码迷,mamicode.com
首页 > 其他好文 > 详细

Es6 之for of

时间:2016-09-05 16:55:59      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

 

 

能工摹形,巧匠窃意。 -- 毕加索

 

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 

 

Es6 之for of

标签:

原文地址:http://www.cnblogs.com/zxyun/p/5842637.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!