The _.flatMap() method creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
Parameters: This method accepts two parameters as mentioned above and described below:
- collection: This parameter holds the collection to iterate over.
- iteratee: This parameter holds the function invoked per iteration.
Return Value: This method returns the new flattened array.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.
[ 35, 35, 47, 47, 58, 58, 69, 69, 94, 94, 13, 13, 72, 72 ]
[ 3.5, 3.5, 4.7, 4.7, 5.8, 5.8, 6.9, 6.9, 9.4, 9.4, 1.3, 1.3, 7.2, 7.2 ] [ 3, 3, 4, 4, 5, 5, 9, 9, 9, 9, 1, 1, 7, 7 ]
- Collect.js flatMap() Method
- Lodash _.method() Method
- Lodash _.sneq() Method
- Lodash _.toQuery() Method
- Lodash _.uniqWith() Method
- Lodash _.xorWith() Method
- Lodash | _.head() Method
- Lodash | _.remove() Method
- Lodash | _.pullAt() Method
- Lodash | _.pullAll() Method
- Lodash | _.pull() Method
- Lodash | _.nth() Method
- Lodash | _.takeRight() Method
- Lodash | _.take() Method
- Lodash | _.sortedLastIndex() Method
- Lodash | _.fromPairs() Method
- Lodash | _.differenceWith() Method
- Lodash | _.castArray() Method
- Lodash | _.cloneDeep() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.