Created
May 1, 2010 05:41
-
-
Save dshaw/386079 to your computer and use it in GitHub Desktop.
Replacing named function reference with arguments.callee
This file contains hidden or 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
// From @jeresig | |
// http://ejohn.org/apps/learn/#15 | |
var ninja = { | |
yell: function(n){ | |
return n > 0 ? arguments.callee(n-1) + "a" : "hiy"; | |
} | |
}; | |
assert( ninja.yell(4) == "hiyaaaa", "arguments.callee is the function itself." ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Though it's worth noting that arguments.callee is deprecated. Further discussion here: http://stackoverflow.com/questions/103598/why-was-the-arguments-callee-caller-property-deprecated-in-javascript