ES6 - Map Method values()


Advertisements

This function returns an iterator that contains the values for each element in the map object.

Syntax

The syntax for values() is as follows −

map_name.values()

Example

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

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

   for(let role of empJobs.values()){
      console.log(role)
   }
</script>

The output of the above code is as mentioned below −

Software Architect
Developer
Advertisements