WeakSetBaseline · Widely available
A WeakSet object stores unique values of any type without creating strong references to the values, such that membership in the set does not prevent garbage collection of the value.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Sep 30, 2015. Widely available since Mar 30, 2018.
Browser support
DesktopChrome
1–35Not supported
36+Supportedsince Jul 16, 2014
Current: 155Edge
12+Supportedsince Jul 29, 2015
Current: 154Firefox
1–33Not supported
34+Supportedsince Dec 1, 2014
Current: 157Safari
1–8Not supported
9+Supportedsince Sep 30, 2015
Current: 27MobileChrome Android
18–35Not supported
36+Supportedsince Jul 16, 2014
Current: 155Firefox Android
4–33Not supported
34+Supportedsince Dec 1, 2014
Current: 157Safari iOS
1–8Not supported
9+Supportedsince Sep 16, 2015
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: WeakSet.
Feature detection
JS · check before using
if (typeof WeakSet !== "undefined") {
// WeakSet is available
}Sub-features
Support for each part of the feature (8). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| WeakSet | 36 | 12 | 34 | 9 | 36 | 34 | 9 |
| WeakSet.WeakSet | 36 | 12 | 34 | 9 | 36 | 34 | 9 |
| WeakSet.WeakSet.iterable_allowed | 38 | 12 | 34 | 9 | 38 | 34 | 9 |
| WeakSet.WeakSet.null_allowed | 36 | 12 | 37 | 9 | 36 | 37 | 9 |
| WeakSet.add | 36 | 12 | 34 | 9 | 36 | 34 | 9 |
| WeakSet.delete | 36 | 12 | 34 | 9 | 36 | 34 | 9 |
| WeakSet.has | 36 | 12 | 34 | 9 | 36 | 34 | 9 |
| WeakSet.symbol_as_keys | 109 | 109 | 146 | 16.4 | 109 | 146 | 16.4 |