ES6 - Collections Set Method has()


Advertisements

Returns a boolean indicating whether an element with the specified value exists in a Set object or not.

Syntax

mySet.has(value);

Parameters

  • Value − The value for which existence check should be done.

Return Value

Returns true if an element with the specified value exists in the Set object; otherwise false.

Example

var mySet = new Set(); 
mySet.add("Jim");  
console.log(mySet.has("Jim"));   
console.log(mySet.has("Tom"));

Output

true 
false
es6_collections.htm
Advertisements