ES6 - Map Method clear()


Advertisements

Removes all key/value pairs from the Map object.

Syntax

myMap.clear();            

Parameters

No parameters

Return Value

Undefined.

Example

var myMap = new Map(); 
myMap.set("bar", "baz"); 
console.log(myMap.size); 

myMap.clear(); 
console.log(myMap.size) 

Output

1 
0    
es6_collections.htm
Advertisements