Set
constructor takes an iterable as argument and populate the elements of
iterator.
Syntax
new
Set(iterable)
HelloWorld.js
var countries = new Array(); countries.push("India"); countries.push("Australia"); countries.push("Canada"); countries.push("Germany"); var countriesSet = new Set(countries) console.log(countries); console.log(countriesSet);
Output
Array(4)
[ "India", "Australia", "Canada",
"Germany" ]
Set(4)
[ "India", "Australia", "Canada", "Germany"
]
No comments:
Post a Comment