多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## flatMap + [link](./flatMap "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L7672 "View in source.") + [npm](https://www.npmjs.com/package/lodash.flatmap "See the npm package.") ``` _.flatMap(collection, [iteratee=_.identity]) ``` 创建一个扁平化的数组,每一个值会传入 iteratee 处理,处理结果会与值合并。 iteratee 会传入3个参数:(value, index|key, array)。 ### 参数 1. collection (Array|Object) 需要遍历的数组 2. [iteratee=_.identity] (Function|Object|string) 这个函数会在每一次迭代调用 ### 返回值 (Array) 返回新数组 ### 示例 ``` function duplicate(n) { return [n, n]; } _.flatMap([1, 2], duplicate); // => [1, 1, 2, 2] ```