Set.prototype.entries()
This
method returns an Iterator object that contains an array of [value, value] for
each element in the Set.
function printSetInfo(set){ console.log("***********************************"); console.log("Number Of Elements : " + set.size); var entries = countries.entries(); /*key and value are same */ for(var [key, value] of entries){ console.log(key); } 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