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

几种对象遍历的方法

时间:2017-04-23 20:44:09      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:json   键值   对象   方法   返回   map对象   map   item   数组   

目前学习了四种对象

1.json对象 用for in遍历 如:for(let item in st){}//返回的是键也是就是属性名。

2.数组对象用for of 遍历时 for(let item of arr){}//返回为值。

3.Set 对象用for of 遍历时 for(let item of arr){}//返回为可以说是键也可以说是值 因为他的键和值 是一样的。

4.Map对象用for of 遍历时 for(let item of arr){}//返回为键值对的数组。

几种对象遍历的方法

标签:json   键值   对象   方法   返回   map对象   map   item   数组   

原文地址:http://www.cnblogs.com/woshinidaye/p/6753851.html

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