-
Notifications
You must be signed in to change notification settings - Fork 0
第 4 题:介绍下 Set、Map、WeakSet 和 WeakMap 的区别? #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
WeakSetWeakSet 结构与 Set 类似,也是不重复的值的集合。但是,它与 Set 有两个区别。
WeakSet 结构有以下三个方法。
|
Map
Object 结构提供了“字符串—值”的对应,Map 结构提供了“值—值”的对应 任何具有 Iterator 接口、且每个成员都是一个双元素的数组的数据结构(详见《Iterator》一章)都可以当作Map构造函数的参数。这就是说,Set和Map都可以用来生成新的 Map。
Map 结构的实例
操作方法
操作方法
遍历方法 Map 的遍历顺序就是插入顺序。
|
WeakMapWeakMap与Map的区别有两点。 这里的区别和 WeakSet与Set的区别类似
WeakMap只有四个方法可用:get()、set()、has()、delete()。 |
Set
Set 实例的属性:
操作方法
遍历方法
The text was updated successfully, but these errors were encountered: