javascript

Merge multiple arrays and strings into single array using Lodash

If you want to merge or combine multiple arrays, string, numbers into a single array using lodash then you can use its _.concat() method.

const str = 50;
const arr1 = [20];
const arr2 = [30, 35];
const arr3 = [[10]]

const final_arr = _.concat(str, arr1, arr2, arr3);

The _.concat() method takes all the arrays and other items as parameter and combine them together to generate a final array.

Live Demo

Was this helpful?