+ 1
What is a callback in JavaScript? I typically read or hear people saying "add a callback to your function or piece of code"
Is callback function just similar to anonymous function? For example while registering onclick event, instead specifying what would happen on click in an altogether separate function, specify the function declaration and implementation directly in that very statement as part of callback. Are there any best practices on where to use callback and where not to use it?
2 odpowiedzi
+ 2
✔best place to understand javascript call back
http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/
+ 1
function is normally called by program immediately for execution.
Callback is a function that would be call by events that would be happened later, eg timer or external api data in functions, which all these functions would not be called immediately due to not times up or data delay.