Skip to content

Instantly share code, notes, and snippets.

@qgustavor
Created April 24, 2014 16:46
Show Gist options
  • Save qgustavor/11261348 to your computer and use it in GitHub Desktop.
Save qgustavor/11261348 to your computer and use it in GitHub Desktop.
Browser recursion test
/** Get the maximum call stack and the error it generates */
(function () {
var results = {};
(function f (a) {
try {
f(a+1);
} catch (e) {
results[a] = e;
}
}(0));
console.log(Object.keys(results).map(function(e){
return e + ' [' + results[e].constructor.name+']: ' + results[e].message;
})[0]);
}());
/* RESULTS */
// Firefox/22.0 -> 7048 [InternalError]: too much recursion
// varies from 6973 up to 7048
// Chrome/35.0.1916.69 -> 9648 [RangeError]: Maximum call stack size exceeded
// Internet Explorer 11 -> 12601 [undefined]: Out of stack space
// varies from 6243 up to 12601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment