--- title: Map.prototype.get() slug: Web/JavaScript/Reference/Global_Objects/Map/get tags: - ECMAScript 2015 - JavaScript - Map - Method - Prototype translation_of: Web/JavaScript/Reference/Global_Objects/Map/get ---
{{JSRef}}

get() 메서드는 Map 객체에서 지정한 요소를 회수합니다.

{{EmbedInteractiveExample("pages/js/map-prototype-get.html")}}

구문

myMap.get(key);

매개변수

key
Map 객체에서 회수할 요소의 키.

반환 값

주어진 키와 연결된 요소. 그런 요소가 없으면 {{jsxref("undefined")}}.

예제

get 사용하기

var myMap = new Map();
myMap.set('bar', 'foo');

myMap.get('bar');  // "foo" 반환.
myMap.get('baz');  // undefined 반환.

명세

Specification Status Comment
{{SpecName('ES2015', '#sec-map.prototype.get', 'Map.prototype.get')}} {{Spec2('ES2015')}} Initial definition.
{{SpecName('ESDraft', '#sec-map.prototype.get', 'Map.prototype.get')}} {{Spec2('ESDraft')}}  

브라우저 호환성

{{Compat("javascript.builtins.Map.get")}}

같이 보기