stack-trace

condensed version of console.trace()

谁说我不能喝 提交于 2020-07-09 05:27:48
问题 JavaScript (browser): I want to find out how deep the stack is. Basically, I want to know how many lines would be printed if I would call console.trace() . But I don't want to call console.trace() (and then count lines in the console window), I just want to 'have' that number of lines in a variable which I can then store to get some kind of performance statistics. Here is an example. function StackTest(limit){ this.inc = -1; this.limit = limit; } StackTest.prototype.test = function(n){ /