Javatpoint Logo
Javatpoint Logo

JavaScript Set has() method

The JavaScript Set has() method indicates whether the Set object contains the specified value. It returns true if the specified value is present, otherwise false.

Syntax

The has() method is represented by the following syntax:

Parameter

value - It represents the value to be searched.

Return

A Boolean value.

JavaScript Set has() method example

Here, we will understand has() method through various examples.

Example 1

Let's see an example to determine whether the set object contains the specified value.

Test it Now

Output:

true

Example 2

Let's see one more example to determine whether the set object contains the specified value.

Test it Now

Output:

false
false






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