解决:JS如何取得当前正在执行的function的名字

代码如下

function getFName(fn){
    return (/^[\s\(]*function(?:\s+([\w$_][\w\d$_]*))?\(/).exec(fn.toString())[1] || '';
}
function test(){
    alert(getFName(arguments.callee));
}
test();

 

posted @ 2016-08-08 15:51  cssfirefly  阅读(2901)  评论(0编辑  收藏  举报
foot