i am very new in jquery. so i was searching google for jquery callback function and i got a code but i did not understand the flow of the code. so please anyone help me to understand the coding flow.
here is the code
function mightyplugin(foo, callback){
// big code block here
callback.apply(this, [foo]);
}
mightyplugin("Bar!", function(param){
alert(param);
});
here i am passing "Bar!"
as one argument to function mightyplugin
and a anonymous function.
- what
callback.apply
does. whatthis
keyword will hold actually.... why it is required. - why
[foo]
is passed as array. what would be the syntax if i pass many argument like
mightyplugin("Bar!","1stone","2ndone", function(param){ alert(param); });
i know callback function invoke when first function finish but here situation is different... why?
please explain...
thanks