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