Create a gist now

Instantly share code, notes, and snippets.

var stackLimit = (function() {
var result = 0;
function recurse() {
result++;
recurse();
}
try {
recurse();
} catch(e) { }
return result;
}());
var o = {
'foo': function() {
return this;
}
};
global.onerror = function(message) {
console.log(message);
};
console.log('About to start the test');
var foo = Function('return o.foo()' + Array(stackLimit + 1).join('.foo()'))();
console.log(foo);
@rwaldron
Owner
About to start the test

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
RangeError: Maximum call stack size exceeded
@jdalton

I typoed, should be:

var foo = Function('return o.foo()' + Array(stackLimit + 1).join('.foo()'))();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment