Saturday, 20 October 2018

JavaScript: Set.prototype.has(value): Check for the existence of an element in the set

Set.prototype.has(value)
This method returns true, if the set has given element, else false.

HelloWorld.js
var countries =  new Set();

countries.add("India");
countries.add("Australia");
countries.add("Canada");
countries.add("Germany");

console.log("Is countries has India ? " + countries.has("India"));
console.log("Is countries has France ? " + countries.has("France"));


Output

Is countries has India ? true
Is countries has France ? false



Previous                                                 Next                                                 Home

No comments:

Post a Comment