The values() function of the Set returns an iterator object which holds the values of the current Set object.The next() method returns the next element in the iterator object.
Syntax
Its Syntax is as follows
setObj.values()
Example
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> const setObj = new Set(); setObj.add('Apples'); setObj.add('Oranges'); setObj.add('Bananas'); setObj.add('Grapes'); var valuesObject = setObj.values(); for(i=0; i<setObj.size; i++) { document.write(valuesObject.next().value); document.write("<br>"); } </script> </body> </html>
Output
Apples Oranges Bananas Grapes