How to iterate over a Set in TypeScript?

后端 未结 5 1921
逝去的感伤
逝去的感伤 2021-01-03 19:36

How do you iterate over a set in TypeScript? for..of does not work:

\'Set\' is not an array type or a string type

.for

5条回答
  •  太阳男子
    2021-01-03 20:42

    This worked for me:

    this.mySet.forEach((value: string, key: string) => {
      console.log(key);
      console.log(value);
    });
    

    I found it here: Other Stack Overflow question

提交回复
热议问题