函数—04函数arguments对象

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_36282409/article/details/83822147
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>New Web Project</title>
    <script type="text/javascript" charset="UTF-8">
        //function参数
        
        //参数列表
        //js中,函数的参数,分为形参、实参。
        function test(a,b,c,d){
            
           // alert(test.length);
            
            
            //函数的实际参数,内部就是用一个数组接收的函数的实际参数。
            //arguments 对象 ,可以访问函数的实际参数。
            //argumets 对象,只能在函数的内部使用。
         
          /*
            alert(arguments.arguments.length);
                          
                          alert(arguments[0]);
                          alert(arguments[1]);
                          */
          /*
          
                          if(test.length==arguments.length){
                              return a+b;
                          }else{
                              
                               return "鍙傛暟涓嶆纭�;
                          }*/
          
          
          /**
           * arguments对象,用的最多的,还是递归操作、a
           * arguments.callee  
           */
                
            function fact(num){
                if(num<=1) return 1;
                else return arguments.callee(num-1);
            }    
                       
        }
        
       //alert(fact(5));//30
         var F = fact;
        fact = null;
        alert(F(5));
        
    </script>
</head>
<body>
    <h1>New Web Project Page</h1>
</body>

猜你喜欢

转载自blog.csdn.net/weixin_36282409/article/details/83822147