Skip to content

Instantly share code, notes, and snippets.

@LeeeeeeM
Created June 20, 2018 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeeeeeeM/d0a60da84802c8d9984116fbd2858635 to your computer and use it in GitHub Desktop.
Save LeeeeeeM/d0a60da84802c8d9984116fbd2858635 to your computer and use it in GitHub Desktop.
Map && WeakMap
// 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