javascript - First class functions- how are even they possible? -


i'm struggling this. i'm reading book , example code works can't head around how. first class functions seem twist , turn, turn inside out , feed in , out of each other magic. goes this:

   var data = {};    data["value1"] = fancymethod.value1 ;    data["value2"] = fancymethod.value2 ;    data["value3"] = fancymethod.value3 ;     getgoing( complexfunction , data);     function getgoing( complexfunction , data){        function setupcomplexfunction(param1, param2){        var param3 = param1.somevalue ;        complexfunction(param1, param2, param3, data);        }      importantfunction(getgoing);      } 

the thing importantfunction() 1 sets processes used retrieve parameters functions feed it.

so params obtained after importantfunction() called. how possible other code inside getgoing() runs ok when when unable obtain params until importantfunction() called?

above simplification of code show concepts i'm struggling with.

actual code:

importantfunction() http.createserver(onrequest).listen(8888);

and getgoing() function runs router , request handlers server. coming php i'm finding strange seems requests , urls , request handlers interpreted before server starts.

source: https://github.com/manuelkiessling/nodebeginner.org/tree/master/code/application

i guess obvious me 1 day wonder if has simple way of explaining now.

importantfunction (which haven't included definition of) will, presumably, call getgoing. @ point can pass whatever arguments likes.

additionally, first time getgoing called, called line:

getgoing( complexfunction , data); 

… doesn't depend on importantfunction @ all.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -