JavaScript – Set forEach()
JavaScript Set.forEach() is used to execute a given function for each of the element in this Set.
Syntax
The syntax to call forEach() method on a Set set1
is
set1.forEach (function(element) { //code })
ADVERTISEMENT
Examples
In the following example, we take a Set with three elements and use forEach() method to execute a function for each of these elements.
index.html
Conclusion
In this JavaScript Tutorial, we learned how to use Set.forEach() method in JavaScript, with examples.