★ wanayoo — archive 1999 https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/getNouvelle recherche | Portail wanayoo
mozilla
Os seus resultados da pesquisa

    WeakMap.prototype.get()

    Nossos voluntários ainda não traduziram este artigo para o Português (do Brasil). Junte-se a nós e ajude a fazer o trabalho!

    This is an experimental technology, part of the ECMAScript 6 (Harmony) proposal.
    Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.

    The get() method returns a specified element from a WeakMap object.

    Syntax

    wm.get(key);

    Parameters

    key
    Required. The key of the element to return from the WeakMap object.

    Return value

    Returns the element associated with the specified key or undefined if the key can't be found in the WeakMap object.

    Examples

    Using the get method

    var wm = new WeakMap();
    wm.set(window, "foo");
    
    wm.get(window); // Returns "foo".
    wm.get("baz");  // Returns undefined.
    

    Specifications

    Specification Status Comment
    ECMAScript 6 (ECMA-262)
    The definition of 'WeakMap.prototype.get' in that specification.
    Release Candidate Initial definition.

    Browser compatibility

    Feature Chrome Firefox (SpiderMonkey) Internet Explorer Opera Safari
    Basic support 36 6.0 (6.0) 11 23 7.1
    Feature Android Firefox Mobile (SpiderMonkey) IE Mobile Opera Mobile Safari Mobile
    Basic support Not supported 6.0 (6.0) Not supported Not supported iOS 8

    Firefox-specific notes

    • Prior to SpiderMonkey 38 (Firefox 38 / Thunderbird 38 / SeaMonkey 2.35), this method threw a TypeError when the key parameter was not an object. However, the latest ES6 standard specifies to return undefined instead. Furthermore, WeakMap.prototype.get accepted an optional second argument as a fallback value, which is not part of the standard. Both non-standard behaviors are removed in version 38 and higher (bug 1127827).

    See also

    Etiquetas do documento e colaboradores

    Contribuíram para esta página: realityking, fscholz
    Última atualização por: fscholz,