手写bind函数没有满足科里化
来源:6-5 作用域相关的面试题 - part1

宝慕林7304498
2020-03-27
双越老师,您好!
在课程中,有一个面试例题叫做“手写bind函数”。我仔细看了您的代码,发现它只能实现作用域绑定,不能实现科里化。这是您的代码:
Function.prototype.bind = function() {
// 将参数拆解为数组
const args = Array.prototype.slice.call(arguments)
// 获取 this (数组第一项)
const t = args.shift()
// fn1.bind(...) 中的 fn1
const self = this
// 返回一个函数
return function() {
return self.apply(t, args)
}
}
写回答
2回答
-
双越
2020-03-27
bind 和 curry 并没有直接关系吧?
122020-06-27 -
宝慕林7304498
提问者
2020-03-27
Function.prototype.bind()是可以实现currying的
012020-03-27
相似问题