Created
May 29, 2015 03:05
-
-
Save msrafi/6ecbe1a306bb8702036e to your computer and use it in GitHub Desktop.
Function name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
/* create functions that can report their own names, | |
by looking into the arguments used to invoke them | |
*/ | |
function FunctionA(){ | |
var fName = arguments.callee.toString().match(/function ([^\(]+)/)[1] | |
alert('Hi, I\'m in a function named '+fName) | |
} | |
function FunctionB(){ | |
alert(arguments.callee.toString().match(/function ([^\(]+)/)[1]); | |
} | |
function FunctionC(){ | |
FunctionA(); | |
FunctionB(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment