Я думаю, что вы можете сделать это:
var name = arguments.callee.toString();
Для получения дополнительной информации об этом, посмотрите на this article.
function callTaker(a,b,c,d,e){
// arguments properties
console.log(arguments);
console.log(arguments.length);
console.log(arguments.callee);
console.log(arguments[1]);
// Function properties
console.log(callTaker.length);
console.log(callTaker.caller);
console.log(arguments.callee.caller);
console.log(arguments.callee.caller.caller);
console.log(callTaker.name);
console.log(callTaker.constructor);
}
function callMaker(){
callTaker("foo","bar",this,document);
}
function init(){
callMaker();
}
мне очень интересно, при каких обстоятельствах имя функции, которую вы находитесь в самом деле не один выписана в коде? – bryantsai
@bryantsai: 'window [window.prompt ('Function name:', '')] = function() {alert (arguments.callee.name); }; ' – Boldewyn