I. Map and WeakMap

A Map can accept various types of values as keys. References to the same object are considered to be the same key, otherwise they cannot be retrieved. Properties: get, set, has, delete, clear traversal: Keys, valuse, forEach, entries (iterate order is insertion order) WeakMap only accepts objects as key values except null. Objects referenced by key names are weak references and will not be included in the garbage collection mechanism and will be deleted automatically once they are not needed. Properties: GET, set, HAS, deleteCopy the code

Second, Set and WeakSet

Size, add, delete, has, clear Array.from (keys, values, entries, forEach) Array.from (keys, values, entries, forEach) Array.from (keys, values, entries, forEach) Array.from (keys, values, entries, forEach) Array.from (keys, values, entries, forEach) Array.from (keys, values, entries) Array. WeakSet (objects) Add,delete, and HAS cannot be traversedCopy the code

Third, Symbol. Iterat

The object used for... Let obj = {0: 'a', 1: 'b', 2: 'c', length: 3, [Symbol. Iterator]: Function () {// index = 0; let next = () => { return { value: this[index], done: this.length == ++index } } return { next } } }Copy the code

4. Symbol Base data type

let s = Symbol(‘any’)

Each Symbol is unique and can be used as a key value.

Keys cannot iterate through properties with Symbol as the key value for obj. External operations can be avoided

Json.stringify is also ignored

You can use Object. GetOwnPropertySymbol (obj) = > [‘ Symbol (‘ name ‘)]

Reflect.ownKeys(obj) traverses Symbol

Attributes can be privatized and only accessible in the current module because Symbol is unique

Symbol.for(‘name’) creates unique symbols under multiple Windows