for_of循环

2018-09-27  本文已影响0人  牛耀

for(let value of target){}循环遍历

  1. 遍历数组
  2. 遍历Set
  3. 遍历Map
  4. 遍历字符串
  5. 遍历伪数组
    let arr = [1,2,3,4,5,5,6,2];
    let arr1 = [];
    let set = new Set(arr);
    for(let i of set){
        console.log(i);
        arr1.push(i);
    }
    console.log(arr1);
    let map = new Map([['aaa', 'username', 25], [36, 'age']]);
    for(let i of map){
        console.log(i);
    }
上一篇 下一篇

猜你喜欢

热点阅读