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

Map.prototype.get() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Map.prototype.get()

Baseline

20157

get() Map (Map) undefined Map

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

console.log(map.get("bar"));
// : "foo"

console.log(map.get("baz"));
// : 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"]

ECMAScript 2027 LanguageSpecification
# sec-map.prototype.get


Web Proxy Viewer  |  New URL  |  Original Page