WeakMap.prototype.get()
O método get()
retorna um elemento especificado de um objeto WeakMap
.
Experimente
Sintaxe
wm.get(chave);
Parâmetros
- chave
-
Obrigatório. A chave do elemento a ser retornado pelo objeto
WeakMap
.
Valor de retorno
O elemento associado à chave especificada no objeto WeakMap
. Se a chave não for encontrada, retorna-se undefined
.
Exemplos
Utilizando o método get
var wm = new WeakMap();
wm.set(window, 'foo');
wm.get(window); // Retorna "foo".
wm.get('baz'); // Retorna undefined.
Especificações
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'WeakMap.prototype.get' in that specification. |
Padrão | Initial definition. |
ECMAScript (ECMA-262) The definition of 'WeakMap.prototype.get' in that specification. |
Padrão em tempo real |
Compatibilidade com navegadores
BCD tables only load in the browser