ES6 Data Structures
ES6 adds two useful and efficient data structures, Set and Map.
Set
Set
is a collection of unique values of any type. It can be initialized empty or with an existing list of items.Map
Map
is key-value map. It can be initialized empty or with an existing array of array. In a Map
key and value can be of any type.WeakSet and WeakMap
WeakSet
is a collection Objects.WeakMap
is a key-value map with Objects as keys.In both of these, References to Objects are weak. So they can be garbage collected, if there is no other reference.