摘要:
functionclone(jsonObj){varbuf;if(jsonObjinstanceofArray){buf=[];vari=jsonObj.length;while(i--){buf[i]=arguments.callee(jsonObj[i]);}returnbuf;}elseif(typeofjsonObj=="function"){returnjsonObj;}elseif(jsonObjinstanceofObject){buf={};for(varkinjsonObj){buf[k]=arguments.callee(jsonObj[k]);}ret 阅读全文
posted @ 2012-09-09 21:49
chenping2008
阅读(2930)
评论(0)
推荐(0)
摘要:
递归函数是在一个函数通过名字调用自身的情况下构成的,如下所示:functionfactorial(num){if(num<=1){return1;}else{returnnum*factorial(num-1);}}这是一个经典的阶乘函数。表面看来没有什么问题,但下面的代码却可能导致它出错。var anotherFactorial = factorial;anotherFactorial(4); //输出 24factorial = null;anotherFactorial (4); //TypeError: Property 'factorial' of object 阅读全文
posted @ 2012-09-09 21:20
chenping2008
阅读(297)
评论(0)
推荐(0)
摘要:
functionselectFrom(lowerValue,upperValue){varchoices=upperValue-lowerValue;returnMath.floor(Math.random()*choices+lowerValue);} 阅读全文
posted @ 2012-09-09 20:48
chenping2008
阅读(178)
评论(0)
推荐(0)
浙公网安备 33010602011771号