I got two functions, passing one of then as parameter, like:
var a = function(f)
{
// some code
f();
};
var b = function()
{
};
a(b); // works great, the function a is executed, then the function b is executed
Now I need to extend it to tree functions, like:
var a = function(f)
{
// some code
f();
};
var b = function(f)
{
// some code
f();
};
var c = function()
{
};
a(b(c)); // but it does not work. b(c) words like a method and get executed right on the instruction.
How can i do that?
It sounds like you want to use a callback kind of pattern. Instead of simply passing along the results of the functions, you would do something like so:
Your code would end up looking like so:
Effectively, you pass along another function to execute after the method finished. In the above scenario, I simply supply two anonymous functions as the callback arguments.