当前位置: 代码迷 >> JavaScript >> js 设立断点技术
  详细解决方案

js 设立断点技术

热度:154   发布时间:2012-09-20 09:36:50.0
js 设置断点技术

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;
}
?
  相关解决方案