Set, Map, Weakset and WeakMap in JavaScript

Set and WeakSet

Set is unique collection of objects. Difference between Set and WeakSet is that in WeakSet, garbage collection may happen when object stored in set gets out of scope. Sets can store primitive as well as non primitive values. Weakset stores only objects. WeakSet does not have size property and methods like keys, values, clear,entries etc.

Map and WeakMap

Set is collection of objects as key and values. Difference between Map and WeakMap is that in WeakMap, garbage collection may happen when object stored in map gets out of scope.

Youtube | Facebook | Twitter | Website Home | Online Grocery Shopping Brisbane