for_of循环

【for_of循环】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); }

    推荐阅读