However there are many methods that I might use other than reduce including methods like the flatten method. With lodash there are a few methods that are a single method that combines the functionality of two methods such as the lodash flatmap method which I will be going over in this post.
So the lodash flatmap method in lodash is one of many methods that I do not use often, and alo it is not such a big deal to just use map, and then flatten. never the less this will be the subject of this post.
The lodash flat map method works more or less the same way as the lodash map method in the sense that the first argument is a collection and the second argument is an iteratee method for each element in the collection. The difference is that an array of results for each element is what is expected to be returned by the iteratee and that array is to be flattened into an array of just one dimension.
To some extent the lodash flatten method is redundant as the same result can be achieved with the lodash map and lodash flatten method by way of chaining.
Maybe one of the best options to go with these days will still involve chaining a few native method that include array map, along with array reduce and array concat.
This solution might still break on older browsers, but often so will lodash code as well in some cases it it is a late version of lodash.