JavaScript Map has() method

The JavaScript map has() method is used to indicate whether the map object contains the specified key element.

Syntax:

mapObj.has(key)

Parameters: key: It represents the specific key that has to be searched.

Return: Returns true if the specified key is present in the map otherwise returns false.

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.has(4));
</script>
</body>
</html>
Please follow and like us:
Content Protection by DMCA.com