Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
738 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var toObject = require('../internals/to-object');
|
---|
3 | var toAbsoluteIndex = require('../internals/to-absolute-index');
|
---|
4 | var toLength = require('../internals/to-length');
|
---|
5 |
|
---|
6 | // `Array.prototype.fill` method implementation
|
---|
7 | // https://tc39.es/ecma262/#sec-array.prototype.fill
|
---|
8 | module.exports = function fill(value /* , start = 0, end = @length */) {
|
---|
9 | var O = toObject(this);
|
---|
10 | var length = toLength(O.length);
|
---|
11 | var argumentsLength = arguments.length;
|
---|
12 | var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
|
---|
13 | var end = argumentsLength > 2 ? arguments[2] : undefined;
|
---|
14 | var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
|
---|
15 | while (endPos > index) O[index++] = value;
|
---|
16 | return O;
|
---|
17 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.