- Hands-On Data Structures and Algorithms with JavaScript
- Kashyap Mukkamala
- 138字
- 2021-06-30 19:12:17
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.
推薦閱讀
- Node.js+Webpack開發(fā)實(shí)戰(zhàn)
- The Modern C++ Challenge
- Mastering ServiceStack
- Cocos2d-x游戲開發(fā):手把手教你Lua語言的編程方法
- 深入淺出Spring Boot 2.x
- Blender 3D Incredible Machines
- 大學(xué)計(jì)算機(jī)基礎(chǔ)(第2版)(微課版)
- 算法訓(xùn)練營:提高篇(全彩版)
- Getting Started with NativeScript
- Nginx Lua開發(fā)實(shí)戰(zhàn)
- 批調(diào)度與網(wǎng)絡(luò)問題的組合算法
- Learning R for Geospatial Analysis
- Vue.js 2 Web Development Projects
- Java語言程序設(shè)計(jì)教程
- Visual Studio 2015高級編程(第6版)