找到调用函数的函数的最佳方法是什么?
例如,如果我有
function first(){
doSomething();
}
// Lots of code
function doSomething(){
alert('Somehow, I know that' + ________ + 'function called me...');
alert('Boink, hit an error, but now you know what function called me');
}
有没有办法获得该调用功能?谢谢!
答案 0 :(得分:3)
将______替换为doSomething.caller
。