-
-
Save LeeeeeeM/d0a60da84802c8d9984116fbd2858635 to your computer and use it in GitHub Desktop.
Map && WeakMap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Map 是 构造函数是 var a = new Map([ [key1, value1], [key2, value2] ]) | |
// key1只要与key2不是同一个引用就不会覆盖。 key1 与key2 可以是任何类型。 | |
// WeakMap 不会进入到垃圾回收机制,当key值清空会自动回收,不进入垃圾回收(垃圾回收里面只要存在引用就不可以被回收,这样可以防止内存泄漏) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment