how is the call back parameter defined?

  • http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them
  • 调用那个callback的函数,其函数体内应标明这个callback的参数是怎么赋值的,即其中应该明确哪些参数及如何赋值给此callback
    • callback的内部逻辑可以用户自己定义
    • 可以pass更多的参数给callback,但在callback逻辑内部要表明如何使用它
    • prototype只是给这一类obj提供base property或method
  • when passing a function as parameter, we only pass the function definition
  • callback is closure
    • When we pass a callback function as an argument to another function, the callback is executed at some point inside the containing function’s body just as if the callback were defined in the containing function. This means the callback is a closure
  • how is the value passed to err, connection?
    • the function which use the call back fundtion should tell how those parameter are used
    • it’s defined in the prototype on how the parameter is used
      • how is the value assigned to the parameter, how is the parameter used actually is defined in the prototype method,
      • db.pool.getConnection(function(err, connection) {...});
Advertisements
This entry was posted in Nodejs. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s