【发布时间】:2020-05-11 00:45:42
【问题描述】:
假设我有这个数据:
const celsius = [-15, -5, 0, 10, 16, 20, 24, 32]
const fahrenheit = celsius.map(t => t * 1.8 + 32);
所以celsius 是一个数组,而fahrenheit 正在使用map,即使用celsius 创建另一个具有以下值的数组:
>[0]
>5
>23
>32
>50
>60.8
>68
>75.2
>89.6
我的问题是它创建的新数组,因为我只需要数组的值,而数组 [0] 使得使用它变得非常困难。所以我的问题是:我可以用.map 创建一个数组而不创建数组[0] 吗?
【问题讨论】:
-
我想你很困惑。 fahrentheit 只包含数字:5、23 等。元素数量与摄氏度数组相同。
-
不清楚你在问什么。你想达到什么目标?
标签: arrays angular array.prototype.map