I have a function like
function a (p1, p2) { /* ... */ }
and in some scope want to get something like this:
function b (/* no params! */) { return a (my1, my2) }
where my1 and my2 are defined somehow in this scope. So I should get a parameterless function b, which when called calls a with fixed parameters my1 and my2. Now, the question is, why this is not right, and which is :)
UPD: Ok, I had some callbacks in those params, now found out, how to process them all. What I missed was to apply the technique twice. Thank you.
Just make a function that returns a new function b:
function getB(my1, my2) {
return function() {
a(my1, my2);
}
}
and use it like this:
var b = getB(my1, my2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With