WeakMap.prototype.has()

O método has() retorna um booleano indicando se um elemento com a chave especificada existe no objeto WeakMap ou não.

Sintaxe

wm.has(chave);

Parameters

chave
Obrigatório. A chave do elemento cuja presença deve ser verificada no objeto WeakMap.

Valor de retorno

Boolean
Retorna true se um elemento com a chave especificada existir no objeto WeakMap. Caso contrário, retorna false.

Exemplos

Utilizando o método has 

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

wm.has(window); // retorna true
wm.has('baz');  // retorna false

Especificações

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'WeakMap.prototype.has' in that specification.
Padrão Initial definition.
ECMAScript Latest Draft (ECMA-262)
The definition of 'WeakMap.prototype.has' in that specification.
Rascunho  

Compatibilidade de navegadores

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
hasChrome Full support 36Edge Full support 12Firefox Full support 6
Notes
Full support 6
Notes
Notes Prior to Firefox 38, this method threw a TypeError when the key parameter was not an object. This has been fixed in version 38 and later to return false as per the ES2015 standard.
IE Full support 11Opera Full support 23Safari Full support 8WebView Android Full support 37Chrome Android Full support 36Firefox Android Full support 6
Notes
Full support 6
Notes
Notes Prior to Firefox 38, this method threw a TypeError when the key parameter was not an object. This has been fixed in version 38 and later to return false as per the ES2015 standard.
Opera Android Full support 24Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
Full support 0.12
Full support 0.10
Disabled
Disabled From version 0.10: this feature is behind the --harmony runtime flag.

Legend

Full support  
Full support
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

Ver também