Definition of Callback:
A Function that is set as a property within a Component. And is usually called when some event occurs on the Component.
For Example:
If you wish to display a dialog which reads "I was clicked" when the user clicks on the Component componentB, you would write a method stored as a variable which does this:
var mouseDownCallbackFunction = function() { alert("I was clicked!"); };
Next, you would set this function inside the component like so…
// Set the Component to display the dialog when the // user presses the mouse down on it. componentB.setMouseDownCallback(mouseDownCallbackFunction);
And this would cause mouseDownCallbackFunction to display "I was clicked" in an alert box when the component was clicked.
In C, that would be a valid callback. However I’m not so familar with JavaScript to say if it is or not because I’m not sure how variables are treated with respect to their memory locations.
In C/C++ you could declare a void pointer:
Would work.
However, despite my lack of JavaScript knowledge, I do know that
is valid as well.
EDIT added a not to the second sentence: ‘I’m not so familar’