![]() |
VOOZH | about |
Lodash _.flatMapDeep() method creates a flattened array of values by running each element in the given collection through the iteratee function and recursively flattens the mapped results. It is similar to the _.flatMap() method.
_.flatMapDeep(collection, iteratee);This method returns the new flattened array.
Example 1: In this example, we are using the _.flatMapDeep() method for duplicating the elements of a given array.
Output:
[
'aaa', 'aaa', 'bbb', 'bbb',
'ccc', 'ccc', 'ddd', 'ddd',
'eee', 'eee'
]
Example 2: In this example, we are using the _.flatMapDeep() method for naking apatter of a given array.
Output:
[
1, '1>', 2, '2>',
3, '3>', 4, '4>',
5, '5>', 6, '6>',
7, '7>'
]
[
'<a', 'a', '<b',
'b', '<c', 'c',
'<d', 'd', '<e',
'e'
]