MDN’s new design is in Beta! A sneak peek:

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

The clear() method used to remove all elements from a WeakSet object, but is no longer part of ECMAScript and its implementations.




Using the clear method

var ws = new WeakSet();

ws.has(window);  // true


ws.has(window); // false


Not part of any current specification or draft. The method was planned for inclusion in ECMAScript 6, but dropped from the draft specification in revision 28 (October 14, 2014). Browser support for the feature was subsequently removed, and it never became part of the final standard.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 36 No support [1] No support 23 No support
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support [1] No support No support No support

[1] Added to Firefox in version 34, but removed in version 46. See bug 1101817.

See also

Document Tags and Contributors

 Contributors to this page: Alhadis, fscholz, claudepache, realityking, teoli
 Last updated by: Alhadis,