withLimited availability
The with JavaScript statement adds a given object to the chain of scopes used to evaluate names.
Not yet supported in all major browsers — check the table and provide a fallback.
Discouraged: JavaScript strict mode prohibits the with statement. Use instead: Destructuring
Browser support
DesktopChrome
1–37Not supported
38+Supportedsince Oct 7, 2014
Current: 155Edge
12+Supportedsince Jul 29, 2015
Current: 154Firefox
1–47Not supported
48+Supportedsince Aug 2, 2016
Current: 157Safari
1–9.1Not supported
10+Supportedsince Sep 20, 2016
Current: 27MobileChrome Android
18–37Not supported
38+Supportedsince Oct 8, 2014
Current: 155Firefox Android
4–47Not supported
48+Supportedsince Aug 2, 2016
Current: 157Safari iOS
1–9.3Not supported
10+Supportedsince Sep 13, 2016
Current: 27How to use
Support is still inconsistent across browsers. Use feature detection and test carefully.
Example
Full syntax and examples are on MDN: Symbol.unscopables.
Feature detection
JS · check before using
// Syntax can't be tested with an if-statement — an unsupported
// browser fails to parse the whole script. Either transpile for older
// targets (e.g. Babel/TypeScript/esbuild), or probe in isolation:
let supported = true;
try {
new Function("/* code that uses the syntax */");
} catch {
supported = false;
}This is a language syntax feature.
Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (3). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Array.@@unscopables | 38 | 12 | 48 | 10 | 38 | 48 | 10 |
| Symbol.unscopables | 38 | 12 | 48 | 9 | 38 | 48 | 9 |
| with | 1 | 12 | 1 | 1 | 18 | 4 | 1 |