Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript Map Complete Reference

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 17 Mar, 2023
Improve Article
Save Article

JavaScript Map is a collection of elements where each element is stored as a key, value pair. Map objects can hold both objects and primitive values as either key or value. When we iterate over the map object it returns the key, and value pair in the same order as inserted.



Example: Below is an example of a Map.forEach() method.


    // Creating a map using Map object
    let mp=new Map()
    // Adding values to the map
    // Logging map object to console





The complete list of JavaScript Map are listed below:

JavaScript Map Constructor: In JavaScript, a constructor gets called when an object is created using the new keyword.



Map()Create Map objects in JavaScript.

JavaScript Map Properties: A JavaScript property is a member of an object that associates a key with a value.

  • Instance Properties: An instance property is a property that has a new copy for every new instance of the class.

    Instance Properties


    constructorIt is used to create a map object.
    sizeReturn the number of keys, and value pairs stored in a map.

JavaScript Map Methods: JavaScript methods are actions that can be performed on objects.

  • Static Methods: If the method is called using the Number class itself then it is called a static method.

    Static Methods


    clear( )Removal of all the elements from a map and making it empty.
    delete()Delete the specified element among all the elements which are present in the map.
    entries( )Returning an iterator object which contains all the [key, value] pairs of each element of the map.
    forEach()The map with the given function executes the given function over each key-value pair.
    get( )Returning a specific element among all the elements which are present in a map.
    has( )Check whether an element with a specified key exists in a map or not.
    keys()The keys from a given map object return the iterator object of keys.
    set()Add key-value pairs to a Map object.
    values()Return a new Iterator object that contains the value of each element present in Map.
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!