0
app.get('/', function (req, res) {
  res.send('Hello World!');
});

I know what to do with above code but I want to up my level so I can know how is it look like at the back.

my guess is below

var app = {

get:function(first, second){
first=  function(){
//do something
},
second = return second(){

}();
}

}

I'm sure my guess is wrong btw..

Jennifer
  • 905
  • 9
  • 20
  • Please clarify what exactly it is you're asking. I don't see a clear problem statement in this question, nor do I even see a question mark. – zzzzBov Jan 11 '16 at 05:27

1 Answers1

0

Callbacks are used to handle async issues, an example would be:

var first = function (callback) {
  var hi = reallyLongFunction();
  return callback(hi);
};

var second = function () {
  first(function(hiFromFirstFunction) {
    //scope of this function has hiFromFirstFunction and anything within the second function
  });
};
Nick Nasirpour
  • 268
  • 1
  • 8