JavaScript Map get() method

The JavaScript map get() method is used to retrieve the value of a specified key.

Syntax:

mapObj.get(key)

Parameters:
key: It represents the specific key corresponding to which value has to be retrieved.

Return:
The value corresponds to a specific key.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var hello=new Map();
hello.set(1,"GOOD MORNING");
hello.set(2,"GOOD AFTERNOON");
hello.set(3,"GOOD EVENING");
hello.set(4,"GOOD NIGHT");
document.writeln(hello.get(1)+"<br>");
document.writeln(hello.get(2)+"<br>");
document.writeln(hello.get(3)+"<br>");
document.writeln(hello.get(4));
</script>
</body>
</html>