Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Samual Sam

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

Live Demo

<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

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.