What are Callback functions ?
A callback function is one that is not invoked explicitly by the programmer; rather the responsibility for its invocation is delegated to another function that receives the callback function’s reference and instructions as to when to run the callback function.
This an excellent quote from wikipedia explaining callback
Think of it as an “In case of fire, break glass” subroutine. Many computer programs tend to be written such that they expect a certain set of possibilities at any given moment. If “Thing That Was Expected”, then “Do something”, otherwise, “Do something else.” is a common theme. However, there are many situations in which events (such as fire) could happen at any time. Rather than checking for them at each possible step (“Thing that was expected OR Things are on fire”), it is easier to have a system which detects a number of events, and will call the appropriate function upon said event (this also keeps us from having to write programs like “Thing that was expected OR Things are on fire OR Nuclear meltdown OR alien invasion OR the dead rising from the grave OR…etc., etc.) Instead, a callback routine is a sort of insurance policy. If zombies attack, call this function. If the user moves their mouse over an icon, call HighlightIcon, and so forth.
Callback functions are nothing new. They have been in C++, php . Most common usage these days you might find in javascript functions and iPhone programming.








