Thursday 15 April 2010

Proper explanation of JavaScript execution order -


I know there are so many questions on this topic, but they are all in accordance with a specific case. I am asking this question and hoping for an answer that everyone can use it while thinking about this matter.

Say that I have three functions that need to be executed in order, and they all do Async

For two tasks it is easy with callback: / P>

  var fOne = function (callback) {// do stuff callback (); }; Var fTwo = function () {// do stuff};   

Calling:

  fOne (fTwo);   

The FOO makes it to run after completion, how does the FTH in this case connect, so that it can be run after FTO, which is run after FOn?

Actually, if I think your question is correct, then you can add a logic to the FTO If you want to pass Lambda, then FTO has to take a callback and call it.

  var fOne = function (callback) {// do stuff callback (); }; Var fTwo = function (callback) {// do stuff callback (); }; Var fThree = function () {// do stuff}; Fun (function () {FTO (FT-2);}); // & lt; - Lambda    

No comments:

Post a Comment