函数内部属性:arguments.callee

2017-06-16 13:45:00
admin
原创
513
<!DOCTYPE html>
<html>
<head>
    <title>Function Type Arguments Example</title>
    <script type="text/javascript">
        
        function factorial(num){
            if (num <= 1) {
                return 1;
            } else {
                return num * arguments.callee(num-1)
            }
        }

        var trueFactorial = factorial;
        
        factorial = function(){
            return 0;
        };
        
        alert(trueFactorial(5));   //120
        alert(factorial(5));       //0


    </script>
</head>
<body>

</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络