You can use bind
to bind variables of a function, and execute the said function later to get the desired result.
You have seen how how closures can be used in Javascript and a bit about currying functions. Here’s one more way of doing that.
We can bind available variables for a function and execute function at a later time.
Consider the below closure -
|
|
We may not want to create another variable doing the same thing for us - do we? Instead we bind one of the values, and do the final execution when the next variable is available.
|
|
Using bind we can now fix variables incrementally and do the final function execution at a later time.