ES6 - Map Method entries()



This function returns an iterator that contains the key-value pairs for each element in the Map.

Syntax

The syntax for entries() is as given below −

map_name.entries()

Example

<script>
   let andy = {ename:"Andrel"},
      varun = {ename:"Varun"},
      prijin = {ename:"Prijin"}

   let empJobs = new Map([
   [andy,'Software Architect'],
   [varun,'Developer']]
   );

   for(let row of empJobs.entries()){
      console.log("key is ",row[0])
      console.log("value is ",row[1])
   }
</script>

The output of the above code is as shown below −

key is {ename: "Andrel"}
value is Software Architect
key is {ename: "Varun"}
value is Developer
Advertisements