Export (0) Print
Expand All

has Method (WeakMap) (JavaScript)

Returns true if the WeakMap object contains the specified element.

weakmapObj.has(key)

weakmapObj

Required. A WeakMap object.

key

Required. The key of the element to test.

true if the WeakMap contains the specified key.

The following example shows how to add a member to a WeakMap and then use has to check whether it is present.

var dog = {
    breed: "yorkie"
}

var wm = new WeakMap();
wm.set(dog, "fido");

document.write(wm.has(dog));

// Output:
// true

Supported in the Internet Explorer 11 standards document mode. Also supported in Store apps (Windows 8.1 and Windows Phone 8.1). See Version Information. Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Not supported in Windows 8.

Show:
© 2014 Microsoft