Set.prototype.forEach(callbackFn[,
thisArg])
This
method calls the callback function for every element in the set.
set.forEach(function(ele){
console.log(ele);
});
function printSetInfo(set){ console.log("***********************************"); console.log("Number Of Elements : " + set.size); set.forEach(function(ele){ console.log(ele); }); console.log("***********************************"); } var countries = new Set(); countries.add("India"); countries.add("Australia"); countries.add("Canada"); countries.add("Germany"); printSetInfo(countries);
Output
***********************************
Number
Of Elements : 4
India
Australia
Canada
Germany
***********************************
No comments:
Post a Comment