JS-07-函数

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <title></title>
 6     </head>
 7     <body>
 8         <script type="text/javascript">
 9 //            使用function关键字定义函数:调用函数和定义函数没有先后
10             demo();
11             function demo(){
12                 alert('函数被调用了');
13             }
14 //           在表达式中定义函数(匿名函数):定义函数和调用函数有先后,定义在前,调用在后
15             var  demo1 = function(){
16                 alert('函数跳出来了');
17             };
18             demo1();
19             
20             
21 //          函数传参
22             function demo2(a,b){
23                 console.log('函数被调用了');
24                 console.log(a,b);
25                 console.log(arguments);
26                 for(i in arguments){
27                     console.log(arguments[i]);
28                 }
29             }
30             demo2(100,200,300,400);
31         </script>
32     </body>
33 </html>

猜你喜欢

转载自www.cnblogs.com/qinqin-me/p/11266797.html