The variable parameter passing

 1 <html lang="en">
 2 <head>
 3     <meta charset="UTF-8">
 4     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 5     <meta http-equiv="X-UA-Compatible" content="ie=edge">
 6     <title>可变传参</title>
 7 </head>
 8 <body>
 9     < Script > 
10          // variable parameter passing 
. 11         / * function CLAC () {
 12 is              // use parameter passing arguments to 
 13 is              List = The arguments.length;
 14              // and if the calculated
 15                 var SUM = 0;
 16                 // not put equal
 . 17              for (var I = 0; I <List; I ++) {
 18 is                  SUM + = arguments [I]
 . 19              }
 20 is              return SUM;
 21 is          }
 22 is          the console.log (CLAC (l, 3,5)) * / 
23 is          // comparing the maximum value of the variable parameter passing 
24          @ function clac(){
25         // var max=0;
26         // list =arguments.length
27         // for(var i=0;i<=list;i++){
28         //     if(arguments[i]>=max){
29         //        max =arguments[i]
30         //     }
31         // }
32         // return max
33 
34         // }
35         // document.write(clac(4,6,2,7,3))
36         //可变传参
37         function Calc(){
38             parsNum=arguments.length;
39             var max =0;
40             for(var i=0;i<parsNum-1;i++){
41                 if(arguments[i]>max){
42                     max=arguments[i]
43                 }
44             }
45             return max
46 
47         }
48         console.log(Calc(6,8,9,3,2,5))
49 
50         </script>
51 </body>
52 </html>

 

Guess you like

Origin www.cnblogs.com/yuanxiangguang/p/11109011.html