arrayConcat.js 599 B

12345678910111213141516171819202122232425
  1. /**
  2. * Creates a new array joining `array` with `other`.
  3. *
  4. * @private
  5. * @param {Array} array The array to join.
  6. * @param {Array} other The other array to join.
  7. * @returns {Array} Returns the new concatenated array.
  8. */
  9. function arrayConcat(array, other) {
  10. var index = -1,
  11. length = array.length,
  12. othIndex = -1,
  13. othLength = other.length,
  14. result = Array(length + othLength);
  15. while (++index < length) {
  16. result[index] = array[index];
  17. }
  18. while (++othIndex < othLength) {
  19. result[index++] = other[othIndex];
  20. }
  21. return result;
  22. }
  23. module.exports = arrayConcat;