@@unscopable 기호 속성은 ES2015 이전 ECMAScript 표준에 포함되지 않은 속성 이름을 포함합니다. 해당 속성들은 with 바인딩에서 제외됩니다.
구문
arr[Symbol.unscopables]
설명
with 바인딩에서 제외되는 배열의 기본 속성은 copyWithin, entries, fill, find, findIndex, includes, keys, values입니다.
자신의 객체에 대해 unscopables를 설정하는 방법은 Symbol.unscopables를 참고하세요.
Property attributes of Array.prototype[@@unscopables] |
|
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | yes |
예제
아래 코드는 ES5 이하에서 잘 작동합니다. 그러나 ECMAScript 2015 이후 Array.prototype.keys() 메서드가 도입되었습니다. 이는 with 내부에서 "keys"가 변수가 아니라 메서드임을 의미합니다. 여기서 Array.prototype[@@unscopables]가 개입하여 일부 배열 메서드가 with 범위에 묶이는 일을 방지합니다.
var keys = [];
with (Array.prototype) {
keys.push("something");
}
Object.keys(Array.prototype[Symbol.unscopables]);
// ["copyWithin", "entries", "fill", "find", "findIndex",
// "includes", "keys", "values"]
명세
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Array.prototype[@@unscopables]' in that specification. |
Standard | Initial definition. |
| ECMAScript (ECMA-262) The definition of 'Array.prototype[@@unscopables]' in that specification. |
Living Standard |
브라우저 호환성
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@unscopables | Chrome Full support 38 | Edge Full support 12 | Firefox Full support 48 | IE No support No | Opera Full support 25 | Safari Full support 10 | WebView Android Full support 38 | Chrome Android Full support 38 | Firefox Android Full support 48 | Opera Android Full support 25 | Safari iOS Full support 10 | Samsung Internet Android Full support 3.0 | nodejs Full support 0.12 |
Legend
- Full support
- Full support
- No support
- No support