- 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.
推薦閱讀
- PHP 7底層設(shè)計(jì)與源碼實(shí)現(xiàn)
- Learning RabbitMQ
- Java開(kāi)發(fā)入行真功夫
- Mastering Python Networking
- Python機(jī)器學(xué)習(xí):手把手教你掌握150個(gè)精彩案例(微課視頻版)
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- Getting Started with React Native
- “笨辦法”學(xué)C語(yǔ)言
- C++ System Programming Cookbook
- Visual C++程序設(shè)計(jì)全程指南
- Serverless工程實(shí)踐:從入門到進(jìn)階
- Instant AppFog
- Java基礎(chǔ)案例教程(第2版)
- Visual C++ 開(kāi)發(fā)從入門到精通
- FORTRAN程序設(shè)計(jì)權(quán)威指南