`has()` 方法根据WeakMap对象的元素中是否存在key键返回一个boolean值。

## 语法

    wm.has(key);

### Parameters

key
  必须的。用来检测WeakMap对象中是否存在元素的键为key。

### Return value

Boolean
  如果指定的key存在于某个元素中则返回true，否则返回flase。

## 例子

### 使用 `has方法`

    var wm = new WeakMap();
    wm.set(window, "foo");

    wm.has(window); // returns true
    wm.has("baz");  // returns false

## 规范

Specification | Status | Comment
--- | --- | ---
ECMAScript 2015 (6th Edition, ECMA-262) WeakMap.prototype.has | Standard | Initial definition.
ECMAScript Latest Draft (ECMA-262) WeakMap.prototype.has | Draft |

## 浏览器兼容

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

- Desktop
- Mobile

Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari
--- | --- | --- | --- | --- | ---
Basic support | 36 | 6.0 (6.0) | 11 | 23 | 7.1

Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile
--- | --- | --- | --- | --- | ---
Basic support | 未实现 | 6.0 (6.0) | 未实现 | 未实现 | 8

## Firefox-特有说明

- 直到SpiderMonkey 38 (Firefox 38 / Thunderbird 38 / SeaMonkey 2.35), 这个方法在key参数不是一个对象时会抛出 `TypeError`。它已经从版本38后按照最新版本的ES6标准修复 (bug 1127827).

## See also

- `WeakMap`
- `WeakMap.prototype.set()`
- `WeakMap.prototype.get()`