JavaScript Set forEach() methodThe 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. SyntaxThe forEach() method is represented by the following syntax: Parametercallback - 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 exampleLet's see a simple example of forEach() method Test it NowOutput: Fetching values : key[jQuery] = jQuery key[AngularJS] = AngularJS key[Bootstrap] = Bootstrap Next TopicJavaScript Set has() Method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India