这是一个仅使用JS的答案在这里。但是,仅仅因为我想更熟练地使用Lodash,所以我寻找 Lodash 的解决方案。
假设我有一个看起来像这样的数组:
假设我有一个看起来像这样的数组:
[[a, b, c], [d, e, f], [h, i, j]]
我想将每个数组的第一个元素作为自己的数组:
[a, d, h]
请问使用 Lodash 最高效的方法是什么?谢谢。
let result = arr.map(a => a[0])
。 - ibrahim mahrirlet result = _.map(arr, a => a[0]);
- ibrahim mahrir