递归与arguments.callee;

 1 <!doctype html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6 </head>
 7 <body>
 8 <script src = "http://libs.useso.com/js/jquery/1.8.3/jquery.min.js"></script>
 9 <script>
10 function fn(num){
11     if(num<1){
12         return 1;
13     }else{
14         //return fn(num-1)*num;此处可以替换
15         return arguments.callee(num-1)*num;
16     }
17 }
18 
19 var a = fn(100);
20     console.log(a)
21 </script>
22 </body>
23 </html>

递归自己调用自己;注意收集此列函数;查看扫雷的递归函数;

posted @ 2015-10-09 14:33  挥刀  阅读(194)  评论(0编辑  收藏  举报