`get()` 方法返回某个 `Map` 对象中的一个指定元素。

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

## 语法

    myMap.get(key);

### 参数

key
  必须参数，也是它唯一的参数，要从目标 `Map` 对象中获取的元素的键。

### 返回值

返回一个 `Map` 对象中与指定键相关联的值，如果找不到这个键则返回 `undefined`。

## 示例

### 使用 `get` 方法

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

    myMap.get("bar");  // 返回 "foo"
    myMap.get("baz");  // 返回 undefined

## 规范

规范 | 状态 | 备注
--- | --- | ---
ECMAScript 2015 (6th Edition, ECMA-262) Map.prototype.get | Standard | Initial definition.
ECMAScript Latest Draft (ECMA-262) Map.prototype.get | Draft |

## 浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

Update compatibility data on GitHub

| Desktop | Mobile | Server
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet | Node.js
`get` | Chrome Full support 38 | Edge Full support 12 | Firefox Full support 13 | IE Full support 11 | Opera Full support 25 | Safari Full support 8 | WebView Android Full support 38 | Chrome Android Full support 38 | Edge Mobile Full support 12 | Firefox Android Full support 14 | Opera Android Full support 25 | Safari iOS Full support 8 | Samsung Internet Android Full support Yes | nodejs Full support Yes

### Legend

Full support
  Full support

## 参见

- `Map`
- `Map.prototype.set()`
- `Map.prototype.has()`