function b(){
console.info("B");
}
function test(){
a(b);
}
在这里, 函数b是以参数形式传给函数a的,那么函数b就叫回调函数。当函数a执行完以后回头去调用函数b
2.使用javascript的call方法实现匿名函数调用
function dosomething(damsg, callback){ console.info(damsg); if(typeof callback == "function") callback.call( damsg ); } funtion test(){ dosomething("回调函数", function(msg){ console.info(msg); }); } 在这里匿名函数 funtion(msg)就是作为回调函数的参数,首先执行dosomething函数,执行完成以后,回头来执行function(msg)这个函数,也就是所谓的回调函数。