1 | var isObject = require('../internals/is-object');
|
2 | var isArray = require('../internals/is-array');
|
3 | var wellKnownSymbol = require('../internals/well-known-symbol');
|
4 |
|
5 | var SPECIES = wellKnownSymbol('species');
|
6 |
|
7 |
|
8 |
|
9 | module.exports = function (originalArray, length) {
|
10 | var C;
|
11 | if (isArray(originalArray)) {
|
12 | C = originalArray.constructor;
|
13 |
|
14 | if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
|
15 | else if (isObject(C)) {
|
16 | C = C[SPECIES];
|
17 | if (C === null) C = undefined;
|
18 | }
|
19 | } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
|
20 | };
|