Your Search Results


    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 has() method returns a boolean indicating whether an element with the specified key exists in the WeakMap object or not.




    Required. The key of the element to test for presence in the WeakMap object.

    Return value

    Returns true if an element with the specified key exists in the WeakMap object; otherwise false.


    Using the has method

    var wm = new WeakMap();
    wm.set(window, "foo");
    wm.has(window); // returns true
    wm.has("baz");  // returns false


    Specification Status Comment
    ECMAScript 6 (ECMA-262)
    The definition of 'WeakMap.prototype.has' 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. This has been fixed in version 38 and later to return false as per latest ES6 standard (bug 1127827).

    See also

    Document Tags and Contributors

    Contributors to this page: realityking, fscholz
    Last updated by: fscholz,