Ways to create a Set in JavaScript?

后端 未结 9 663
太阳男子
太阳男子 2021-01-31 07:06

In Eloquent JavaScript, Chapter 4, a set of values is created by creating an object and storing the values as property names, assigning arbitrary values (e.g. true) as property

9条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 07:33

    Sets do not allow duplicate entries and don't typically guarantee predefined ordering. Arrays do both of these, thus violating what it means to be a set (unless you do additional checks).

提交回复
热议问题