But push() accepts only one parameter.
(但是push()仅接受一个参数。)
So why do we have .push(callback(a))(那么为什么会有.push(callback(a)))
The return value of callback(a)
is only one parameter.
(的返回值callback(a)
只有一个参数。)
why not just .push(a)?
(为什么不只是.push(a)?)
The point of mapping is to take an array of data and create a new array where each item is transformed in some way.
(映射的重点是获取一个数据数组并创建一个新数组,其中每个项目都以某种方式进行转换 。)
If you didn't pass a
through the callback function, it wouldn't be transformed, and you'd just be making a shallow copy.
(如果您没有通过回调函数传递a
,则该函数将不会被转换,而您只是制作一个浅表副本。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…