CodesJava

Easy learning with example program codes

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 have to be retrieved.

Return:
Value corresponding to 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>

Output:

GOOD MORNING
GOOD AFTERNOON
GOOD EVENING
GOOD NIGHT
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status