Javatpoint Logo
Javatpoint Logo

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.

Test it Now

Output:

true 

Example 2

Let's see one more example to determine whether the map object contains the specified key.

Test it Now

Output:

false

Example 3

Let's see the result when has() method is used without specifying key.

Test it Now

Output:

false
false

Next TopicJavaScript Math





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA