2017-12-15 10:56:14 -08:00
|
|
|
/** Used for built-in method references. */
|
|
|
|
var objectProto = Object.prototype;
|
|
|
|
|
|
|
|
/** Used to check objects for own properties. */
|
|
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes an array clone.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {Array} array The array to clone.
|
|
|
|
* @returns {Array} Returns the initialized clone.
|
|
|
|
*/
|
|
|
|
function initCloneArray(array) {
|
|
|
|
var length = array.length,
|
2021-05-08 05:39:21 -07:00
|
|
|
result = new array.constructor(length);
|
2017-12-15 10:56:14 -08:00
|
|
|
|
|
|
|
// Add properties assigned by `RegExp#exec`.
|
|
|
|
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
|
|
|
result.index = array.index;
|
|
|
|
result.input = array.input;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = initCloneArray;
|