[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Map/set [Back]  [Original]

Map.prototype.set() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Map.prototype.set()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

Map set() Map .

In this article

const map1 = new Map();
map1.set("bar", "foo");

console.log(map1.get("bar"));
// Expected output: "foo"

console.log(map1.get("baz"));
// Expected output: undefined

js
set(key, value)

key

Map . JavaScript ( Javascript ) .

value

Map . JavaScript ( Javascript ) .

Map .

set()

js
const myMap = new Map();

// map   
myMap.set("bar", "foo");
myMap.set(1, "foobar");

// map  
myMap.set("bar", "baz");

set()

set() Map .

js
//    .
myMap.set("bar", "foo").set(1, "foobar").set(2, "baz");

Specification
ECMAScript 2027 LanguageSpecification
# sec-map.prototype.set


Web Proxy Viewer  |  New URL  |  Original Page