21. lodash-map方法的区别

1/27/2023 js

lodash-map方法的区别

const _ = require('lodash')

console.log(_.map(['22', '13', '10'], parseInt))  // [ 22, NaN, 2 ]
// parseInt(字符串,多少进制(代表要使用的数字系统的数字(从 2 到 36),可选参数)) 函数解析字符串并返回整数
// parseInt('2', 0, Array)
// parseInt('13', 1, Array)
// parseInt('10', 2, Array)


const fp = require('lodash/fp')
console.log(fp.map(parseInt, ['22', '13', '10']))  // [ 22, 13, 10 ]

// lodash中的map方法的函数接受的参数:(value, index|key, collection) ---> (值、索引、数组)
// lodash/fp中的map方法的函数接受的参数:(value) ---> (值)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
最近更新时间: 2/4/2023, 10:01:08 AM
    강남역 4번 출구
    Plastic / Fallin` Dild