請幫我解決以下問題。在JS功能中獲取來電者姓名
var test = new Object();
test.testInner = new Object();
test.testInner.main = function()
{
Hello();
}
function Hello()
{
/**** Question: currently I am getting blank string with below code,
**** Is there any way to get function name as "test.testInner.main" over here? */
console.log(arguments.callee.caller.name);
}
test.testInner.main();
你可能想看看這個回溯函數:http://snipplr.com/view/23047/ – h2ooooooo
你爲什麼要將調用者的名字寫入日誌而不是使用調試器,並且看着堆棧跟蹤? – PhonicUK
@ PhonicUK,是的。 – SunnyShah