C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Set has() methodThe 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: setObj.has(value) Parameter
value - It represents the value to be searched. ReturnA Boolean value. JavaScript Set has() method example
Here, we will understand has() method through various examples. Example 1Let's see an example to determine whether the set object contains the specified value.
<script>
var set = new Set();
set.add("jQuery");
set.add("AngularJS");
set.add("Bootstrap");
document.writeln(set.has("Bootstrap"));
</script>
Output: true Example 2Let's see one more example to determine whether the set object contains the specified value.
<script>
var set = new Set();
set.add("jQuery");
set.add("AngularJS");
set.add("Bootstrap");
document.writeln(set.has()+"<br>");
document.writeln(set.has(5));
</script>
Output: false false
Next TopicJavaScript Set values() Method
|