首先,我不知道这个方法能怎么应用,仅仅知道这是一种无副作用的方法(虽然看似多余的丑陋的怪异的方法,),而且有浏览器兼容性问题,不知道ecma-262是如何定义caller的.
function foo(s){ if (!s){ f.caller=function(s){alert('ya......'+s)}; f(); }else alert(s); } function f(){ var caller=arguments.callee.caller; delete arguments.callee.caller; arguments.callee.caller('foo'); caller('foo'); } foo();