Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js Map

const result = new Map();//create a new map

result.set('a', 1);
result.set('b', 2);
console.log(result);

const germany = {name: 'Germany' , population: 8000000};//create a new object
result.set(germany, '80m');//set the object to the map

console.log(result);

result.delete('a');//delete the key 'a'
console.log(result);
result.clear();//clear all the keys in the map
console.log(result);
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #js #Map
ADD COMMENT
Topic
Name
6+9 =