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

Map.prototype.get() - 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.get()

Baseline Widely available

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

get() Map . , 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
get(key)

key

Map

Map undefined.

get()

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

console.log(myMap.get("bar")); // "foo"  .
console.log(myMap.get("baz")); // undefined  .

get()

js
const arr = [];
const myMap = new Map();
myMap.set("bar", arr);

myMap.get("bar").push("foo");

console.log(arr); // ["foo"]
console.log(myMap.get("bar")); // ["foo"]

. WeakMap .

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


Web Proxy Viewer  |  New URL  |  Original Page