Sunday 21 October 2018

JavaScript: Set.prototype.keys(): Return an iterator that contain all the values in set

Set.prototype.keys()
This method returns an iterator that contain all the values in set

HelloWorld.js
var countries =  new Set();

countries.add("India");
countries.add("Australia");
countries.add("Canada");
countries.add("Germany");

var iter = countries.keys();

for(var country of iter){
  console.log(country);
}


Output
India
Australia
Canada
Germany



Previous                                                 Next                                                 Home

No comments:

Post a Comment