日期:2014-05-16 浏览次数:20354 次
function inspect(inspector,title){ var expression,result; if('ignore' in arguments.callee) return ; while(true){ var message=''; if(title) message=title+'\n'; if(expression) message+='\n'+expression+'==>'+result+'\n'; else expression=''; message+='enter an expression to evaluate'; expression=prompt(message,expression); if(!expression) return; result=inspector(expression); } } function factorial(n){ var inspector=function($){return eval($);} inspect(inspector,'enterion factorial()'); var result=1; while(n>1){ result=result * n;; n--; inspect(inspector,'factorial() loop'); } inspect(inspector,'exiting factorial()'); return result; }?