Get the current function name in JavaScript

This should do it:

var fn = arguments.callee.toString().match(/function\s+([^\s\(]+)/);
alert
(fn[1]);

For the caller, just use caller.toString().

 

 

alert(arguments.callee.nom);


alert(arguments.callee.name)

 

posted @ 2012-11-21 14:18  alxe_yu  阅读(256)  评论(0)    收藏  举报