ES6——Set、Map

Set:

Commonly used methods are: the Add (), the Clear (), the Delete (), forEach (), has ()

Create a way

let oS = new Set();

Brackets can be passed values ​​are:

The brackets can be passed values ​​are [] '' arguments NodeList

 

 Set Another special feature is that you can go heavy. The value passed to remove the same brackets

 

 add () which added to the set

delete () Deletes

 

 clear () Clear

 

 has () to determine if there is anything you want to the value I have just returned true, no return flase

 

 () Which traverse the set value forEach

 

ES6 new cycle for of () may traverse the inside of the value

 

 Set to turn into an array

 

 Set to turn into an array

 Next we look at the application Set

Union

 

 Intersection

 

 Difference set

 

 Map

Common method where you can find, these methods can all be used. Be used

 Create a way

let oM = new Map();

Incoming way

 

 Probably about the same common method is the way you can view the prototype method calls the

Here I will not take you a trial of a

 

 Traversal

Pre learn more, please venue to:  http://es6.ruanyifeng.com/#docs/set-map

Guess you like

Origin www.cnblogs.com/yangpeixian/p/11595418.html