add-to-unscopables.js 666 B

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