JavaScript Collections
ECMAScript2015(ES6) introduced four new collections Map
, Set
, WeakMap
and WeakSet
.
Map
A Map
object is a simple key/value map and can iterate its elements
in insertion order.
Set
A Set
object is a collection of values. A value in a set may only
occur once. You can iterate its elements in insertion order.
WeakMap
A WeakMap
is a collection of key/value pairs in which the keys are
weakly referenced. The keys must be objects. They allow for objects
which are no longer needed to be cleared from memory.
There is no method to obtain a list of the keys.
WeakSet
A WeakSet
is a collection of objects. References to objects are held weakly.
If no other references to an object stored in the WeakSet
exist , those objects
can be garbage collected.
References
Categories :
JavaScript
ES6