【发布时间】:2020-09-15 07:30:22
【问题描述】:
我不确定使用的术语(我认为它被称为“lambda”或类似的东西),所以我无法进行适当的搜索。
Python 中的以下行:
a, b, c, d, e = [SomeFunc(x) for x in arr]
我怎样才能在 Javascript 中做同样的事情?
我有这个开始:
let [a, b, c, d, e] = arr;
但我仍然需要在 arr 中的每个元素上调用 SomeFunc。
【问题讨论】:
-
叫做列表推导,javascript没有这种东西
-
映射数组项。
let [a, b, c, d, e] = arr.map(someFunc);
标签: javascript python