Interview Questions

What is Callback and Functions ?

jQuery Interview Questions and Answers


(Continued from previous question...)

What is Callback and Functions ?

A callback is a function that is passed as an argument to another function and is executed after its parent function has completed. The special thing about a callback is that functions that appear after the "parent" can execute before the callback executes. Another important thing to know is how to properly pass the callback.

Callback without arguments

$.get('myhtmlpage.html', myCallBack);

Callback with arguments
$.get('myhtmlpage.html', function(){
myCallBack('foo', 'bar');
});

(Continued on next question...)

Other Interview Questions