Map-- common attributes and methods

1.size attribute: Returns the total number of structural members Map

const map = new Map([

  [ 'Name', 'John Doe'],

  ['title','Author']

])

console.log(map.size) // 2

 

2.set and get

3.has method: returns a Boolean value, a key to determine whether the object them in the current Map

map.has('name') //true

4.delete method - returns true success

5. The method of traversing --- 3 walker generating function, a traversal methods

keys () - Returns the key names walker

values ​​() - Returns the key iterator

entries () - Returns all members of the walker

forEach () - all members of traversing Map

Guess you like

Origin www.cnblogs.com/fdxjava/p/11693995.html