• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • Set.prototype[@@iterator]()

    The initial value of the @@iterator property is the same function object as the initial value of the values property.

    语法

    mySet[Symbol.iterator]
    

    返回值

    The Setiterator function, which is the values() function by default.

    示例

    Using [@@iterator]()

    var mySet = new Set();
    mySet.add("0");
    mySet.add(1);
    mySet.add({});
    
    var setIter = mySet[Symbol.iterator]();
    
    console.log(setIter.next().value); // "0"
    console.log(setIter.next().value); // 1
    console.log(setIter.next().value); // Object
    

    Using [@@iterator]() with for..of

    var mySet = new Set();
    mySet.add("0");
    mySet.add(1);
    mySet.add({});
    
    for (var v of mySet) {
      console.log(v);
    }