Sunday, 21 October 2018

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

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

HelloWorld.js
var countries =  new Set();

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

var iter = countries.values();

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

Output
India
Australia
Canada
Germany




Previous                                                 Next                                                 Home

No comments:

Post a Comment