Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

concat.js 1007B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var arrayPush = require('./_arrayPush'),
  2. baseFlatten = require('./_baseFlatten'),
  3. copyArray = require('./_copyArray'),
  4. isArray = require('./isArray');
  5. /**
  6. * Creates a new array concatenating `array` with any additional arrays
  7. * and/or values.
  8. *
  9. * @static
  10. * @memberOf _
  11. * @since 4.0.0
  12. * @category Array
  13. * @param {Array} array The array to concatenate.
  14. * @param {...*} [values] The values to concatenate.
  15. * @returns {Array} Returns the new concatenated array.
  16. * @example
  17. *
  18. * var array = [1];
  19. * var other = _.concat(array, 2, [3], [[4]]);
  20. *
  21. * console.log(other);
  22. * // => [1, 2, 3, [4]]
  23. *
  24. * console.log(array);
  25. * // => [1]
  26. */
  27. function concat() {
  28. var length = arguments.length;
  29. if (!length) {
  30. return [];
  31. }
  32. var args = Array(length - 1),
  33. array = arguments[0],
  34. index = length;
  35. while (index--) {
  36. args[index - 1] = arguments[index];
  37. }
  38. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  39. }
  40. module.exports = concat;