相关疑难解决方法(0)

Javascript - 数组上的 flatMap 方法 - (flatMap 不是函数)

根据 Mozilla 开发者网站:

The flatMap() method first maps each element using a mapping function, then flattens the result into a new array. It is identical to a map followed by a flat of depth 1, but flatMap is often quite useful, as merging both into one method is slightly more efficient.

例子:

let arr = [1, 2, 4, 2, 3, 3, 4, 5, 5, 5, 8, 8, 9, 10];

const flatMap = arr.flatMap(x => x);
console.log(flatMap);
Run Code Online (Sandbox Code Playgroud)

TypeError: arr.flatMap() is not …

javascript arrays node.js ecmascript-6 flatmap

17
推荐指数
2
解决办法
2万
查看次数

标签 统计

arrays ×1

ecmascript-6 ×1

flatmap ×1

javascript ×1

node.js ×1