标签:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> //仅声明了函数,不会自执行,报错 function aa(){ console.log(‘aa‘); }() //自执行情况 </script> <script> //自执行情况 //小括号 (function(){ console.log(‘a1‘); })(); //赋值操作 var a = function(){ console.log(‘a2‘); }(); //逻辑运算符 !function(){ console.log(‘a3‘); }(); //数学运算符 +function(){ console.log(‘a4‘); }(); </script> </body> </html>
注意所写的代码是声明还是执行..
标签:
原文地址:http://www.cnblogs.com/mauricechans/p/5795062.html