1、forEach遍历:
map.forEach(function(value,key){ console.log(value,key); }); 函数中第一个参数是属性值,第二个参数是属性
2、for-of遍历:ES6新语法 ①for(let item of map){ } 遍历结果是数组 ②for(let item of map.values()){ } 遍历属性值 ③for(let item of map.keys()){ } 遍历属性 3、entries遍历:
for(let item of map.entries()){ }
var list1 = ["number","name"]; var list2 = ["36","Crown","15","Faker","Swift","68","Dandy"]; var map_demo = { name: "John", lang: "JS" };
1.最常用的for循环
for(var i=0;i
关注
打赏
热门博文
- ArrayList c.toArray might (incorrectly) not return Object[] (see 6260652)
- Spring框架实体bean转json返回前端报错:Null key for a Map not allowed in JSON (use a converting NullKeySerializer
- python将数据写入txt文本文件
- Python学习随笔:使用xlwings读取和操作Execl文件
- org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unrecognized t
- ‘gbk‘ codec can‘t decode byte 0x80 in position 2: illegal multibyte sequence
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UX
- 关于Mybatis中keyProperty属性
- 解决 Mybatis 报错 org.apache.ibatis.ognl.NoSuchPropertyException: XXXCriteria$Criterion.noValue
- mysql报错 is longer than the server configured value of ‘wait_timeout‘