This is an experimental technology, part of the Harmony (ECMAScript 6) 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.
Summary
The delete() method removes the specified element from a WeakMap object.
Syntax
wm.delete(key);
Parameters
- key
-
Required. The key of the element to remove from the
WeakMapobject.
Return value
Returns true if an element in the WeakMap object has been removed successfully.
Examples
Example: Using the delete method
var wm = new WeakMap(); wm.set(window, "foo"); wm.delete(window); // Returns true. Successfully removed. wm.has(window); // Returns false. The window object is no longer in the WeakMap.
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript Language Specification 6th Edition (ECMA-262) | Draft | Initial definition. |
Browser compatibility
| Feature | Chrome | Firefox (SpiderMonkey) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | (Yes)[1] | 6.0 (6.0) | 11 | Not supported | Not supported |
| Feature | Android | Firefox Mobile (SpiderMonkey) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | Not supported | 6.0 (6.0) | Not supported | Not supported | Not supported |
[1] The feature is available behind a pref. Go to chrome://flags and activate the entry “Enable Experimental JavaScript”.