esnext.array.with.js 500 B

123456789101112131415
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var global = require('../internals/global');
  4. var arrayWith = require('../internals/array-with');
  5. var toIndexedObject = require('../internals/to-indexed-object');
  6. var Array = global.Array;
  7. // `Array.prototype.with` method
  8. // https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.with
  9. $({ target: 'Array', proto: true }, {
  10. 'with': function (index, value) {
  11. return arrayWith(toIndexedObject(this), Array, index, value);
  12. }
  13. });