JavaScript Map keys() method

The JavaScript map keys() method is used to retrieve an object of Map iterator that contains the keys for each element.

Syntax:

mapObj.keys()

Return:
An object of Map iterator.

Example:

<!DOCTYPE html>
<html>
<body>
<script>  
var hello=new Map();  
hello.set('a',"GOOD MORNING");
hello.set('b',"GOOD AFTERNOON");
hello.set('c',"GOOD EVENING");  
hello.set('d',"GOOD NIGHT");  
var array= hello.keys();  
document.writeln(array.next().value+"<br>");  
document.writeln(array.next().value+"<br>");  
document.writeln(array.next().value+"<br>");  
document.writeln(array.next().value);  
</script>  
</body>
</html>

Output:

a
b
c
d
Please Share