UNPKG

669 BJavaScriptView Raw
1'use strict';
2var wellKnownSymbol = require('../internals/well-known-symbol');
3var create = require('../internals/object-create');
4var defineProperty = require('../internals/object-define-property').f;
5
6var UNSCOPABLES = wellKnownSymbol('unscopables');
7var ArrayPrototype = Array.prototype;
8
9// Array.prototype[@@unscopables]
10// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
11if (ArrayPrototype[UNSCOPABLES] === undefined) {
12 defineProperty(ArrayPrototype, UNSCOPABLES, {
13 configurable: true,
14 value: create(null)
15 });
16}
17
18// add a key to Array.prototype[@@unscopables]
19module.exports = function (key) {
20 ArrayPrototype[UNSCOPABLES][key] = true;
21};