VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-concat-function/

⇱ Lodash _.concat() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.concat() Function

Last Updated : 30 Aug, 2024

Lodash _.concat() function is used to concatenate the arrays in JavaScript. and it returns the new concatenated array.

Syntax:

_.concat(array, [values]);

Parameters:

  • array: It is an array to which values are to be added.
  • values: It is the Array of values that is to be added to the original array.

Note: The array value can also contain arrays of an array or simply a single object to be added to the original array.

Return Value:

  • This function returns the array after concatenation.

Example 1: In this example, we are concatenating two arrays having numbers and string as a value by the use if the _concat() method.

Output:

👁 Image

Example 2: In this example, we are concatenating two arrays having numbers,strings and sub array as a value by the use if the _concat() method.

Output:

👁 Image

Example 3: In this example, we are concatenating two arrays having numbers, strings, and object as a value by the use if the _concat() method.

Output:

👁 Image
Comment