Created
April 14, 2012 12:14
-
-
Save tobie/2384002 to your computer and use it in GitHub Desktop.
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
// Why you don't need arguments.callee: | |
var factorial = function callee(n) { | |
if (n === 0) { | |
return 1; | |
} | |
return n * callee(n - 1); | |
}; | |
// In a standard compliant ES3 or ES5 implementation: | |
factorial(1); // -> 1 | |
factorial(2); // -> 2 | |
factorial(3); // -> 6 | |
factorial(5); // -> 120, etc… | |
callee; // -> ReferenceError: callee is not defined | |
// Of course, the latter isn't true in < IE9. See | |
// http://kangax.github.com/nfe/ for details. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment