Javatpoint Logo
Javatpoint Logo

JavaScript Set forEach() method

The JavaScript Set forEach() method executes the specified function once for each value in the Set object. It maintains an insertion order.

Unlike Map, the Set object doesn't use key externally. To keep the values unique it uses the key internally. Thus, Set considers the value of element as a key.


The forEach() method is represented by the following syntax:


callback - It represents the function to execute.

value1, value2 - The value1 represents the key of the element whereas value2 represents the value. Both arguments contains the same value.

set - It represents the current Set object.

thisArg - It represents the value that treats as this when executing callback.

JavaScript Set forEach() method example

Let's see a simple example of forEach() method

Test it Now


Fetching values :
key[jQuery] = jQuery
key[AngularJS] = AngularJS
key[Bootstrap] = Bootstrap

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA