Skip to content

Instantly share code, notes, and snippets.

@tobie
Created April 14, 2012 12:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobie/2384002 to your computer and use it in GitHub Desktop.
Save tobie/2384002 to your computer and use it in GitHub Desktop.
// 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