_.flatten(array)
减少一级array
嵌套深度。
const_=require('lodash'); vararr= [1, 3, 4, [7, 7], 9]; console.log(_.flatten(arr))
_.flattenDeep(array)
将array
递归为一维数组。
const_=require('lodash'); vararr= [1, 3, 4, [7, 7], 9]; console.log(_.flattenDeep(arr))
_.flattenDepth(array, [depth=1])
根据 depth
递归减少 array
的嵌套层级
const_=require('lodash'); vararr= [1, 3, 4, [7, 7], 9]; console.log(_.flattenDepth(arr, 1))