07.立即执行函数.html 737 B

123456789101112131415161718192021222324252627282930
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <script>
  9. /*
  10. 立即执行函数
  11. 函数定义完,立即被调用,这种函数叫做立即执行函数
  12. 立即执行函数往往只会执行一次(因为没有变量保存它,也没有函数名)
  13. */
  14. // (function(){
  15. // alert('我是一个匿名函数');
  16. // })();
  17. (function(a,b){
  18. console.log('a='+a);
  19. console.log('b='+b);
  20. })(12,34);
  21. </script>
  22. </head>
  23. <body>
  24. </body>
  25. </html>