70
JavaScript Map has() method
The JavaScript map has() method indicates whether the Map object contains the specified key. It returns true if the specified key is present, otherwise false.
Syntax
The has() method is represented by the following syntax:
Parameter
key – It represents the key to be searched.
Return
A Boolean value.
JavaScript Map has() method example
Here, we will understand has() method through various examples.
Example 1
Let’s see an example to determine whether the map object contains the specified key.
Output:
true
Example 2
Let’s see one more example to determine whether the map object contains the specified key.
Output:
false
Example 3
Let’s see the result when has() method is used without specifying key.
Output:
false false
Next TopicJavaScript Math