提示lodash 中的函数组合的方法 _.flowRight()
提示:以下是本篇文章正文内容,下面案例可供参考
一、
1.引入库
代码如下(示例):
const _ = require('lodash')
2.读入数据
代码如下(示例):
const reverse = arr => arr.reverse() // 倒叙
const first = arr => arr[0] // 选取第一个
const toUpper = s => s.toUpperCase() // 转化为大写字母
const f = _.flowRight(toUpper, first, reverse)
// flowRight 方法是从右往左执行的
console.log(f(['one', 'two', 'three']))
// 所以打印出来是 THREE