MCPcopy Create free account
hub / github.com/dashnowords/imfe / flatmap

Function flatmap

chapter05/example5-2.js:17–26  ·  view source on GitHub ↗
(arr, result)

Source from the content-addressed store, hash-verified

15
16//数组扁平化
17function flatmap(arr, result){
18 if(isArray(arr)){
19 arr.map(item=>{
20 flatmap(item,result);
21 });
22 }else{
23 result.push(arr);
24 }
25 return result;
26}
27
28//判断传入的是否是一个数组
29function isArray(data) {

Callers 1

getAllFoodFunction · 0.85

Calls 1

isArrayFunction · 0.70

Tested by

no test coverage detected