I have a function in javascript
function foo(callback) { console.log("Hello"); callback(); }
and other function
function bar() { console.log("world"); }
and I want to make a FooBar function
FooBar = foo.bind(this, bar);
This works fine, however, what I'm actually trying to do is create a function queue , and often I will have to bind the function parameter to none before bind the callback, as in the following example
function foo() { console.log(arguments[0]); var func = arguments[1]; func(); } function bar() { console.log("world"); } foo.bind(this, "hello"); var FooBar = foo.bind(this, bar); FooBar();
which produces this error
[Function: bar] TypeError: undefined is not a function
How can I bind a function to another function when it is bound to other types of functions?
source share