Skip to content

Instantly share code, notes, and snippets.

@mrgenixus
Forked from talentedmrjones/arguments.callee.js
Created March 24, 2014 17:51
Show Gist options
  • Save mrgenixus/9745450 to your computer and use it in GitHub Desktop.
Save mrgenixus/9745450 to your computer and use it in GitHub Desktop.
(function (n) { // function has no name, is therefore "anonymous"
var i=n*2;
if (i > 4) {
return undefinedFunc(); // causes a "ReferenceError: undefinedFunc is not defined at Object.<anonymous>"
} else {
arguments.callee(i); // recurses, adding the anonymous function to the call stack
}
})(1);
(function factor (n) { // function has a name, is not "anonymous"
var i=n*2;
if (i > 4) {
return undefinedFunc(); // causes a "ReferenceError: undefinedFunc is not defined at factor"
} else {
factor(i); // recurses, adding named function to the call stack
}
})(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment