//立即执行函数的括号可以包括函数加参数,可以匿名也可以不匿名
//eg1:(function (){}())
//eg2:(function(){})()
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> var test = (function(a) { alert("立即1"+a); this.a = a; return function(b) { alert("立即2"+a); return this.a + b; } }(function(a, b) { alert("立即3"+a); return a; }(1, 2))); (function ceshi(c){ alert(c) }(45)); console.log(test(4)); //输出5 //执行顺序 //31 //11 //45 //21 </script> </body> </html>