日期:2014-05-16  浏览次数:20362 次

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;
}
?