JavaScript Map set() method

The JavaScript map set() method adds a new or modifies the already existing key-value pairs to Map object.

Syntax:

mapObj.set(key,value)

Parameters:
key: It represents the key of the newly added map object.
value: It represents the value of the newly added map object.

Return:
Updated map object.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var map=new Map();
map.set('a',"GOOD MORNING");
map.set('b',"GOOD AFTERNOON");
map.set('c',"GOOD EVENING");
map.set('d',"GOOD NIGHT");
var itr= map.keys();
for(i=0;i<map.size;i++){
document.writeln(itr.next().value+"<br>");
}
</script>
</body>
</html>