Skip to content

JavaScript map values() | Method

  • by

Use the JavaScript map values() method to get the value for each element in the object. This method returns a new iterator object that contains the values for each element in the Map object in insertion order.


JavaScript map values

Simple example code.

<!DOCTYPE html>
  <script >
    const mapObj = new Map();

    mapObj.set('0', 'foo');
    mapObj.set(1, 'bar');

    const iterator = mapObj.values();



JavaScript map values Method

Another example using for loop

<script >
    const obj = new Map();
    obj.set('0', 'foo');
    obj.set(1, 'bar');

    var itr=obj.values();

    for(i=0; i<obj.size; i++)  

Do comment if you have any doubts or suggestions on this Js map method topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *