官术网_书友最值得收藏!

The API difference

The API difference as documented in WeakMap case of maps is pretty close to what you can find for Sets as well:

  • Set.prototype.size: Returns the size of the set
  • Set.prototype.add: Adds a value for a given element and returns the entire new set
  • Set.prototype.delete: Deletes an element and returns true if delete was successful, otherwise false
  • Set.prototype.has: Checks the set for the presence of an element and returns a Boolean
  • Set.prototype.clear: Clears the set and returns nothing
  • Set.prototype.forEach: Loops over the set and gives access to each element
  • Set.prototype.values: Returns an iterator, which can be used to get access to the next value
  • Set.prototype.keys: Similar to values—returns access to values in the set

WeakSet, on the other hand, does not contain the forEach(), keys(), and values() methods for reasons discussed previously.

主站蜘蛛池模板: 富阳市| 资阳市| 正镶白旗| 潮州市| 临沧市| 慈利县| 阜平县| 桑日县| 德安县| 贵南县| 禹州市| 涞水县| 沐川县| 英山县| 唐山市| 儋州市| 抚顺市| 郧西县| 德庆县| 周口市| 如东县| 徐闻县| 日喀则市| 南汇区| 垫江县| 积石山| 金湖县| 濉溪县| 四川省| 通江县| 库车县| 阜康市| 罗甸县| 富锦市| 乌兰察布市| 江城| 金湖县| 张家口市| 花垣县| 姜堰市| 高青县|