ES6 (data structure)

One, set usage

 

set converts an array

Adding duplicate elements doesn't work

 

(Application: Deduplication function) The conversion process will not have data type conversion

 

Add, delete, determine whether there is a method

2.

 

  

Several methods of reading (traversing)

 二、WeakSet

The difference with Set:

1. The elements of WeakSet can only be objects

2. The object of WeakSet is a weak application (it will not detect whether it has been used in other applications, and is not linked to the recycling mechanism)

3. Cannot be traversed, some properties and methods of Set are not available

 

 1.

 can only be objects

 

3. Map

1. The method of generating a Map object

1.

2.

 

 2. Common property values ​​and methods

(Map traversal is the same as Set method)

 

 4. WeakMap

The difference between WeakMap and Map is the same as the difference between WeakSet and Set

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325071969&siteId=291194637