Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
832 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var fails = require('../internals/fails');
|
---|
4 | var createProperty = require('../internals/create-property');
|
---|
5 |
|
---|
6 | var ISNT_GENERIC = fails(function () {
|
---|
7 | function F() { /* empty */ }
|
---|
8 | // eslint-disable-next-line es/no-array-of -- required for testing
|
---|
9 | return !(Array.of.call(F) instanceof F);
|
---|
10 | });
|
---|
11 |
|
---|
12 | // `Array.of` method
|
---|
13 | // https://tc39.es/ecma262/#sec-array.of
|
---|
14 | // WebKit Array.of isn't generic
|
---|
15 | $({ target: 'Array', stat: true, forced: ISNT_GENERIC }, {
|
---|
16 | of: function of(/* ...args */) {
|
---|
17 | var index = 0;
|
---|
18 | var argumentsLength = arguments.length;
|
---|
19 | var result = new (typeof this == 'function' ? this : Array)(argumentsLength);
|
---|
20 | while (argumentsLength > index) createProperty(result, index, arguments[index++]);
|
---|
21 | result.length = argumentsLength;
|
---|
22 | return result;
|
---|
23 | }
|
---|
24 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.