2011-09-06 28 views
1

可能重複裏面的功能:
Can I get the name of the currently running function in javascript?
Get function name in javascript有什麼辦法,在JavaScript中,獲得函數的名稱,這是所謂

有什麼辦法,在JavaScript中,獲取函數的名稱,在被調用的函數內部。

function something() { 
    console.log("The name of the function you invoke is " ...should says 'something'); 
} 
+0

這同樣的問題在這裏回答:http://stackoverflow.com/questions/1013239/can-i-get-the-name-of-the-currently-running-function-in-javascript –

回答

0

是的。

function something(){ 
    alert(arguments.callee.name); 
} 
+0

在其他MSIE中不起作用,並且已被棄用:https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments/callee – BalusC

相關問題