Set
has a property ‘size’, it specifies number of elements in the set.
HelloWorld.js
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