add柯里化实例
class Curry {
constructor() {
this.array = []
}
add() {
if(arguments.length) {
console.log(arguments)
this.array = [...this.array, arguments[0]]
return this.add.bind(this)
} else {
return this.array.reduce((p, c) => p += c)
}
}
}
let curry = new Curry()
curry.add(1)(2)(3)() // return 6
312

被折叠的 条评论
为什么被折叠?



