core-js
Version:
Standard library
18 lines • 643 B
JavaScript
;
var $def = require('./$.def')
, toObject = require('./$.to-object')
, toIndex = require('./$.to-index')
, toLength = require('./$.to-length');
$def($def.P, 'Array', {
// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
fill: function fill(value /*, start = 0, end = @length */){
var O = toObject(this, true)
, length = toLength(O.length)
, index = toIndex(arguments[1], length)
, end = arguments[2]
, endPos = end === undefined ? length : toIndex(end, length);
while(endPos > index)O[index++] = value;
return O;
}
});
require('./$.unscope')('fill');