16. lodash中的组合函数

1/27/2023 js

# lodash中的组合函数

  • lodash中组合函数flow()或者flowRight(),他们都可以组合多个函数
  • flow()是从左到右运行
  • flowRight()是从右到左运行,使用的更多一些
const _ = require('lodash')

const reverse = arr => arr.reverse()
const first = arr => arr[0]
const toUpper = s => s.toUpperCase()

const f = _.flowRight( toUpper, first, reverse)
console.log(f(['one', 'two', 'three']))  // THREE
1
2
3
4
5
6
7
8
最近更新时间: 2/4/2023, 10:01:08 AM
강남역 4번 출구
Plastic / Fallin` Dild