Array.prototype[Symbol.unscopables]

The [Symbol.unscopables] data property of Array.prototype is shared by all Array instances. It contains property names that were not included in the ECMAScript standard prior to the ES2015 version and that are ignored for with statement-binding purposes.

Value

A null-prototype object with property names given below and their values set to true.

Property attributes of Array.prototype[Symbol.unscopables]
Writableno
Enumerableno
Configurableyes

Description

The default Array properties that are ignored for with statement-binding purposes are:

Array.prototype[Symbol.unscopables] is an empty object only containing all the above property names with the value true. Its prototype is null, so Object.prototype properties like toString won't accidentally be made unscopable, and a toString() within the with statement will continue to be called on the array.

See Symbol.unscopables for how to set unscopable properties for your own objects.

Examples

Imagine the values.push('something') call below is in code that was written prior to ECMAScript 2015.

js
var values = [];

with (values) {
  values.push("something");
}

When ECMAScript 2015 introduced the Array.prototype.values() method, the with statement in the above code started to interpret values as the values.values array method instead of the external values variable. The values.push('something') call would break because it's now accessing push on the values.values method. This caused a bug to be reported to Firefox (Firefox Bug 883914).

So the [Symbol.unscopables] data property for Array.prototype causes the Array properties introduced in ECMAScript 2015 to be ignored for with statement-binding purposes — allowing code that was written prior to ECMAScript 2015 to continue working as expected, rather than breaking.

Specifications

Specification
ECMAScript® 2027 Language Specification
# sec-array.prototype-%symbol.unscopables%

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
[Symbol.unscopables]
Chrome – Full support
Chrome 38 (Release date: 2014-10-07)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 48 (Release date: 2016-08-02)
footnote Full support
Opera – Full support
Opera 25 (Release date: 2014-10-15)
footnote Full support
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 38 (Release date: 2014-10-08)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Opera Android – Full support
Opera Android 25 (Release date: 2014-10-16)
footnote Full support
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 3 (Release date: 2015-04-10)
footnote Full support
WebView Android – Full support
WebView Android 38 (Release date: 2014-10-08)
footnote Full support
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 0.12 (Release date: 2015-02-06)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also