UNPKG

652 BJavaScriptView Raw
1var wellKnownSymbol = require('../internals/well-known-symbol');
2var create = require('../internals/object-create');
3var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
4
5var UNSCOPABLES = wellKnownSymbol('unscopables');
6var ArrayPrototype = Array.prototype;
7
8// Array.prototype[@@unscopables]
9// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
10if (ArrayPrototype[UNSCOPABLES] == undefined) {
11 createNonEnumerableProperty(ArrayPrototype, UNSCOPABLES, create(null));
12}
13
14// add a key to Array.prototype[@@unscopables]
15module.exports = function (key) {
16 ArrayPrototype[UNSCOPABLES][key] = true;
17};