Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Standard built-in objects
  5. Map
  6. Map()

Map() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

TheMap() constructor createsMap objects.

Syntax

js
new Map()new Map(iterable)

Note:Map() can only be constructed withnew. Attempting to call it withoutnew throws aTypeError.

Parameters

iterableOptional

If aniterable object (such as an array) is passed, all of its elements will be added to the newMap. Each element must be an object with two properties:0 and1, which correspond to the key and value (for example,[[1, "one"],[2, "two"]]). If you don't specify this parameter, or its value isnull orundefined, the newMap is empty.

Examples

Creating a new Map

js
const myMap = new Map([  [1, "one"],  [2, "two"],  [3, "three"],]);

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-map-constructor

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp