Iterable迭代
遍历数组
<script>
var arr=[3,4,5]
for (var x of arr){ //var x in arr打印的是下标
console.log(x);//3,4,5
}
</script>
使用Iterable遍历map,set
遍历map
var map=new Map([['tom',100],['jack',90],['maria',80]]);
for (let x of map){
console.log(x);
}
遍历set
var set=new Set([3,1,2]);
for (let x of set){
console.log(x);
}