美文网首页
[10,20,30,40].map(parseInt)的返回值

[10,20,30,40].map(parseInt)的返回值

作者: 泡杯感冒灵 | 来源:发表于2020-07-25 15:34 被阅读0次

map() 方法返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值。

[10,20,30,40].map(parseInt)

// 等价于
[10, 20, 30, 40].map((num, index) => {
  return parseInt(num,index)
})

const res  =[10, 20, 30, 40].map((num, index) => {
  return parseInt(num,index)
})
console.log(res)  // [10, NaN, NaN, NaN]

相关文章

网友评论

      本文标题:[10,20,30,40].map(parseInt)的返回值

      本文链接:https://www.haomeiwen.com/subject/xqfmlktx.html