ES6 - Collections Set Method forEach


Advertisements

This function executes the specified function once per each Map entry.

Syntax

myMap.forEach(callback[, thisArg])

Parameters

  • callback − Function to execute for each element.

  • thisArg − Value to use as this when executing callback.

Return Value

Undefined.

Example

function userdetails(values) { 
   console.log(values); 
}  
var mySet = new Set(); 
mySet.add("John"); 
mySet.add("Jane"); 
mySet.forEach(userdetails); 

Output

John 
Jane 
es6_collections.htm
Advertisements