1, the callback is a function of the call process, function A has a parameter, this parameter is a function B, when function a executes after the execution of function B,
Then this process is called a callback.
eg.
function A (callback) { alert (' parent '); Alert (' callback '); Callback ();} function B () { alert (' B ');} A (b);
Operation Result:
Parent
Callback
B
2. When will the callback be executed?
callback functions are typically executed at the end of the synchronization scenario and are not executed in an asynchronous situation because the event is not triggered or
Condition not satisfied
3, the callback function uses the occasion
(1) Resource loading: Execute callback after dynamically loading JS file, execute callback after loading IFRAME, Ajax operation Callback, picture loading complete
Execute callbacks, etc.
(2) Dom events and node. JS events based on callback mechanism
(3) SetTimeout delay time is 0, this hack is often used, settimeout call function is actually a callback
The embodiment
(4) Chained calls
Callback in JS (used when blocking synchronous or asynchronous)