append.js 418 B

123456789101112131415161718192021
  1. /**
  2. * Appends an array to the end of another.
  3. * The first array will be modified.
  4. */
  5. function append(arr1, arr2) {
  6. if (arr2 == null) {
  7. return arr1;
  8. }
  9. var pad = arr1.length,
  10. i = -1,
  11. len = arr2.length;
  12. while (++i < len) {
  13. arr1[pad + i] = arr2[i];
  14. }
  15. return arr1;
  16. }
  17. module.exports = append;