Set.prototype.add(value)
add
method appends an element to set.
Example
countries.add("India");
countries.add("Australia");
countries.add("Canada");
countries.add("Germany");
function printSetInfo(set){ console.log("***********************************"); console.log("Number Of Elements : " + set.size); for(var key of countries){ console.log(key); } console.log("***********************************"); } var countries = new Set(); countries.add("India"); countries.add("Australia"); countries.add("Canada"); countries.add("Germany"); printSetInfo(countries);
Output
***********************************3
Number
Of Elements : 4
India
Australia
Canada
Germany
***********************************
No comments:
Post a Comment