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.
Experimente
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 objetoWeakMap
. Caso contrário, retornafalse
.
Exemplos
Utilizando o método has
js
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 (ECMA-262) The definition of 'WeakMap.prototype.has' in that specification. |
Padrão em tempo real |
Compatibilidade com navegadores
BCD tables only load in the browser