The _.concat()
method in Lodash is used to create a new array by concatenating two or more arrays.
_.concat(array, [values])
This method accepts the following parameters:
array
: The array to be concatenated.[values]
: The values to be concatenated.This method returns a concatenated array.
Let’s look at an example of the _.concat()
method in the code snippet below:
In the HTML tab:
lodash
script.In the JavaScript tab:
_.concat()
method to concatenate both the arrays.In the output, we see an array in which both the arrays are concatenated.