I have a function in javascript
function foo(callback) {
console.log("Hello");
callback();
}
and another function
function bar() {
console.log("world");
}
and I want to make a function FooBar
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 a none function parameter before binding a 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 a I bind a function to another function once it has been bound to other none function types?