CodeW3C Online Tutorial
  • HTML Series Tutorial
  • Browser Script
  • Server Script
  • Programming Tutorial
  • XML Series Tutorial
  • Website Building Manual
  • Reference Manual

Schedule

JS Reference Manual

  • JS Reference Manual (Category Order)
  • JS Reference Manual (Alphabetical Order)

JavaScript

  • JS Array
  • JS Boolean
  • JS Class
  • JS Date
  • JS Error
  • JS Global
  • JS JSON
  • JS Map
  • JS Math
  • JS Number
  • JS Promise
  • JS RegExp
  • JS Set
  • JS String
  • JS Object
  • JS Operator
  • JS Operator Precedence
  • JS Statement
  • JS Typed Array

Window

  • Window Object
  • Window Console
  • Window History
  • Window Location
  • Window Navigator
  • Window Screen

HTML DOM

  • HTML Document
  • HTML Element
  • HTML Attribute
  • HTML Event
  • HTML Event Object
  • HTML Collection
  • HTML NodeList
  • HTML DOMTokenList
  • HTML Style

Web API

  • API Canvas
  • API Console
  • API Fetch
  • API Fullscreen
  • API Geolocation
  • API History
  • API MediaQueryList
  • API Storage
  • API Validation
  • Web API

HTML Object

  • <a>
  • <abbr>
  • <address>
  • <area>
  • <article>
  • <aside>
  • <audio>
  • <b>
  • <base>
  • <bdo>
  • <blockquote>
  • <body>
  • <br>
  • <button>
  • <canvas>
  • <caption>
  • <cite>
  • <code>
  • <col>
  • <colgroup>
  • <datalist>
  • <dd>
  • <del>
  • <details>
  • <dfn>
  • <dialog>
  • <div>
  • <dl>
  • <dt>
  • <em>
  • <embed>
  • <fieldset>
  • <figcaption>
  • <figure>
  • <footer>
  • <form>
  • <head>
  • <header>
  • <h1> - <h6>
  • <hr>
  • <html>
  • <i>
  • <iframe>
  • <img>
  • <ins>
  • <input> button
  • <input> checkbox
  • <input> color
  • <input> date
  • <input> datetime
  • <input> datetime-local
  • <input> email
  • <input> file
  • <input> hidden
  • <input> image
  • <input> month
  • <input> number
  • <input> password
  • <input> radio
  • <input> range
  • <input> reset
  • <input> search
  • <input> submit
  • <input> text
  • <input> time
  • <input> url
  • <input> week
  • <kbd>
  • <label>
  • <legend>
  • <li>
  • <link>
  • <map>
  • <mark>
  • <menu>
  • <menuitem>
  • <meta>
  • <meter>
  • <nav>
  • <object>
  • <ol>
  • <optgroup>
  • <option>
  • <output>
  • <p>
  • <param>
  • <pre>
  • <progress>
  • <q>
  • <s>
  • <samp>
  • <script>
  • <section>
  • <select>
  • <small>
  • <source>
  • <span>
  • <strong>
  • <sub>
  • <summary>
  • <sup>
  • <table>
  • <tbody>
  • <td>
  • <tfoot>
  • <th>
  • <thead>
  • <tr>
  • <textarea>
  • <time>
  • <title>
  • <track>
  • <u>
  • <ul>
  • <var>
  • <video>

    • Other reference manuals
    • CSSStyleDeclaration

    JS type conversion

    Elective courses

    • CodeW3C.com Treasure Box

    JavaScript new Map()

    • Previous Page new Map()
    • Next Page clear()
    • Go Up One Level JavaScript Map Reference Manual

    Course recommendation:

    new Map() Definition and usage

    The constructor is used to create Map objects.

    Note new Map() Map objects can only be created through

    to construct.

    Instance

    Example 1 new Map() Constructor is used to create Map objects by passing an array to:

    // Create a Map
    const fruits = new Map([
      ["apples", 500],
      ["bananas", 300],
      ["oranges", 200]
    ]);
    

    Try it yourself

    Example 2

    Create a new Map object and use set() Method to add elements:

    // Create a Map
    const fruits = new Map();
    // Set the value of Map
    fruits.set("apples", 500);
    fruits.set("bananas", 300);
    fruits.set("oranges", 200);
    

    Try it yourself

    Syntax

    new Map(iterable)

    Parameter

    Parameter Description
    iterable Optional. An iterable object containing key-value pairs.

    Return value

    Type Description
    Object New Map object.

    Browser support

    Map is a feature of ECMAScript6 (ES6).

    Starting from June 2017, all modern browsers support ES6 (JavaScript 2015):

    Chrome Edge Firefox Safari Opera
    Chrome 51 Edge 15 Firefox 54 Safari 10 Opera 38
    May 2016 April 2017 June 2017 September 2016 June 2016

    Map is not supported in Internet Explorer.

    Related Pages

    Tutorial:JavaScript Map

    Tutorial:JavaScript Iterable Objects

    Reference:JavaScript Map

    • Previous Page new Map()
    • Next Page clear()
    • Go Up One Level JavaScript Map Reference Manual

    Toolbox

    JavaScript and HTML DOM Reference Manual
    JavaScript Examples
    JavaScript Quiz
    JavaScript Tutorial

    Sponsor Links

    The content provided by CodeW3C.com is for training and testing purposes only and does not guarantee the accuracy of the content. Risks associated with the use of this site's content are not related to this site. All rights reserved.

    About CodeW3C.com Help CodeW3C.com Terms of Use Privacy Terms Powered by Ce4e.com