_sub-array-dummy-safe.js 606 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var setPrototypeOf = require('../object/set-prototype-of')
  3. , isExtensible = require('./_is-extensible');
  4. module.exports = (function () {
  5. var SubArray;
  6. if (isExtensible) return require('./_sub-array-dummy');
  7. if (!setPrototypeOf) return null;
  8. SubArray = function () {
  9. var arr = Array.apply(this, arguments);
  10. setPrototypeOf(arr, SubArray.prototype);
  11. return arr;
  12. };
  13. setPrototypeOf(SubArray, Array);
  14. SubArray.prototype = Object.create(Array.prototype, {
  15. constructor: { value: SubArray, enumerable: false, writable: true,
  16. configurable: true }
  17. });
  18. return SubArray;
  19. }());