25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
692 B

3 년 전
  1. /** Used for built-in method references. */
  2. var objectProto = Object.prototype;
  3. /** Used to check objects for own properties. */
  4. var hasOwnProperty = objectProto.hasOwnProperty;
  5. /**
  6. * Initializes an array clone.
  7. *
  8. * @private
  9. * @param {Array} array The array to clone.
  10. * @returns {Array} Returns the initialized clone.
  11. */
  12. function initCloneArray(array) {
  13. var length = array.length,
  14. result = new array.constructor(length);
  15. // Add properties assigned by `RegExp#exec`.
  16. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  17. result.index = array.index;
  18. result.input = array.input;
  19. }
  20. return result;
  21. }
  22. module.exports = initCloneArray;