iterator

ES6新特性

遍历数组

//通过for of /for in 下标
    let arr = [1,5,4,7];
    for(let a of arr){
        console.log(a);
    }

遍历Map

    let map = new Map([['tom',11],['jack',15],['bruce',17]]);
    for (let a of map){
        console.log(a);
    }

遍历Set

xxxxxxxxxx4 1 let set = new Set([5,7,8]); 
 for (let a of set){3      
 console.log(a);4   }

 

posted @ 2022-07-07 23:31  少时凌云志  阅读(50)  评论(0)    收藏  举报