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?
Similar Posts
- Combine or merge two or multiple arrays into single array in Javascript
- Lodash - merge two arrays and remove duplicates from it
- how to merge two dimensional array into one dimensional
- Break an array into fixed length array groups using lodash in Javascript
- Lodash - Get common values from multiple arrays
- Assign items of arrays to multiple variable when creating it (Array Destructuring) Javascript(ES6)
- Lodash - Flatten an array to single level deep