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

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.

主站蜘蛛池模板: 油尖旺区| 绥棱县| 苏尼特左旗| 佳木斯市| 淮安市| 辽中县| 都兰县| 眉山市| 金寨县| 武强县| 封开县| 盘锦市| 雅江县| 桂阳县| 广灵县| 长寿区| 万荣县| 平南县| 西和县| 屏南县| 武威市| 渑池县| 花莲县| 崇义县| 屯昌县| 新竹市| 出国| 宝清县| 南丹县| 赤壁市| 盈江县| 台南市| 杭锦旗| 滁州市| 江都市| 修水县| 清流县| 徐闻县| 射洪县| 旌德县| 运城市|