所以我有一个有咖喱方法的课
class myClass {
constructor () {}
curry (a,b) {
return (a,b) => {}
}
}现在可以用咖喱创建另一种方法了吗?就像这样
class myClass {
constructor () {}
curry (a,b) {
return (a,b) => {}
}
newMethod = curry()
}发布于 2017-03-20 15:27:10
是的,您可以很容易地做到这一点--只需将其放入构造函数中:
class MyClass {
constructor() {
this.newMethod = this.curriedMethod('a') // partial application
}
curriedMethod(a) {
return (b) => {
console.log(a,b);
}
}
}
let x = new MyClass();
x.newMethod('b')https://stackoverflow.com/questions/42898930
复制相似问题