Examples of callback functions and anonymous functions in Javascript
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Insert title here</title><script type="text/javascript">//= = = = = = = = = = = = = = = = = = ordinary function callback = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =//Callback the action to be performedfunction callback(){alert(" Please help me go to the express ");}//I was about to dofunction goShopping(a,fun){alert(" I went to shopping the ");//Something to do before 10 o 'clockif(a<10){fun();}}//The callback testgoShopping(9,callback);//This small example is a scenario in which a callback function is used: while some function is executing, without knowing what the future might hold,//And at the same time, when certain conditions are met, you do something else, which is you destroy the function.//= = = = = = = = = = = = = = = = = = ordinary function callback = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =//= = = = = = = = = = = = = = = = = anonymous function callback = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =//I was about to dofunction goShopping(a,fun){alert(" I went to shopping the ");//Something to do before 10 o 'clockif(a<10){fun();}}goShopping(9,function(){alert(" Help me to the express ");});//= = = = = = = = = = = = = = = = = anonymous function callback = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =//= = = = = = = = = = = = = = = = = anonymous functions themselves call = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =function(){alert(" I have no name. How does it work ");}();//=============== =====function(name){alert(" I am a "+name);function test(){" I'm a secret agent! "};//To call the internal test externallywindow.test=test;}("javaScript");//Calls the inner function of the self-tuning functiontest();//So jquery and other js frameworks are written in accordance with the above way oh.//= = = = = = = = = = = = = = = = = anonymous functions themselves call = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</script></head><body></body></html>