ES6 - Set Method has()



Returns true if element found, otherwise it returns false.

Syntax

Below mentioned is the syntax for has(), where, value is the value to search for in the Set.

set_name.has(value)

Example

<script>
   let names = new Set(['A','B','C','D']);
   console.log(names.has('B'))
</script>

The output of the above code is as follows −

true
Advertisements