回调函数

 1 <script>
 2     
 3     //执行函数就等于:函数名+();   整个函数+();
 4 //    1.fn();
 5 //    2.(function(){})()
 6 
 7     fn(test);
 8     fn(demo);
 9     //回调函数:函数作为参数进行传递和使用。
10     function fn(demo){
11         demo();
12         test();
13     }
14 
15     function test(){
16         console.log("我是被测试的函数!");
17     }
18     function demo(){
19         console.log("wishing被测试的函数!");
20     }
21 
22 </script>
//回调函数一般是用于定义一个规则来使用的。
//规则的传递只能通过函数实现。通过变量无法达成。所以我们需要传递规则的时候必须使用回调函数。
原文地址:https://www.cnblogs.com/my12-28/p/11739519.html