前言:Map数据集可以理解为加强版的对象
一、for...of
1、对象不能用于for of,因其没有部署Iterator接口;其他数据集如:数组、Map、Set、Iterator对象等都可以用for...of2、使用for...of的优势:
for of的循环体中可以使用break(跳出循环)、continue、return(跳出方法)
二、Map相关API(实例方法或属性)
1、初始化
let map = new Map([['a', 1],['b', 2],['c', 3],
])2、增删改查
set() delete() clear() get()
3、其他
has() size
三、Map相关内容的遍历(entries() keys() values()实例方法或属性)
map | [object Map] | for of遍历(迭代中的item为数组) |
map.entries() | [object Map Iterator] | for of遍历(迭代中的item为数组) |
map.keys() | [object Map Iterator] | for of遍历 |
map.values() | [object Map Iterator] | for of遍历 |