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 entries() function of Map object returns an iterator of the corresponding Map object and using this you can retrieve the key Value pairs of the map.

Syntax

Its Syntax is as follows

mapVar.entries()

Example

Live Demo

<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <script type="text/javascript">
         var mapVar = new Map();
         mapVar.set('1', 'Java');
         mapVar.set('2', 'JavaFX');
         mapVar.set('3', 'HBase');
         mapVar.set('4', 'Neo4j');          
         var it = mapVar.entries();
         for(i=0; i<mapVar.size; i++) {
            document.write(it.next().value);
            document.write(" <p> ");
         }
      </script>
   </body>
</html>

Output

1,Java

2,JavaFX

3,HBase

4,Neo4j

Example

Live Demo

<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <script type="text/javascript">
         var mapVar = new Map();
         mapVar.set('1', 'Raju');
         mapVar.set('2', 'Ram');
         mapVar.set('3', 'Rahim');
         mapVar.set('4', 'Robert');          
         var it = mapVar.entries();
         document.write(it.next().value);
         document.write("<br>");
         document.write(it.next().value);
      </script>
   </body>
</html>

Output

1,Raju
2,Ram

Advertisements

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