Reputation: 12509
I try to curry a function, which I define in a class someClass
like this:
class SomeClass extends AnotherClass {
_someFunc(arg1) {
const foo = arg1.map(bar => {
return function(arg2) {
bar[arg2];
}
});
return foo;
}
yetAnotherMethod() {
...
somenewFunc()
}
someMethod()
...
const someNewFunc = this._someFunc(someVar)("abc");
....
}
In the same class, I have a method someMethod()
where I try to calll my
When I start my App I get
this._someFunc(...) is not a function
Why is that?
Upvotes: 0
Views: 87
Reputation: 138567
You may do:
const someNewFunc = this._someFunc(someVar)[0]("abc");
SomeFunc returns an Array. This will take the first function out of that array and calls it. If you want to get all values in an array, may do:
_someFunc(arg1,arg2) {
return arg1.map(bar =>bar[arg2]);
}
const someNewFunc = this._someFunc(someVar,"abc");
Or if you want it to be a function:
_someFunc(arg1) {
return function(arg2){
return arg1.map(bar =>bar[arg2]);
}
}
const someNewFunc = this._someFunc(someVar)("abc");
Upvotes: 1