Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
The WeakSet() constructor creates WeakSet objects.
Note: WeakSet() can only be constructed with new. Attempting to call it without new throws a TypeError.
If an iterable object is passed, all of its elements will be added to the new WeakSet. null is treated as undefined.
Note that foo !== bar. While they are similar objects, they are not the same object. And so they are both added to the set.
| ECMAScript® 2027 Language Specification # sec-weakset-constructor |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 10, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.