0

This is my code:

 foo();
 var test;

  function foo(){
    function bar() {
      test = console.trace();
    }
    bar();
  }

  console.log(test);

It logs out the following:

bar VM246:9 
foo VM246:2 
(anonymous function) VM232:777 
InjectedScript._evaluateOn VM232:710 
InjectedScript._evaluateAndWrap VM232:626 
InjectedScript.evaluate VM246:12 
undefined

So, according to the logs the trace while test is undefined.

Is there a way to catch data from console.trace()?

Lets say, I need the number 5 for the bar and number 7 for the foo.

Robert
  • 1,286
  • 1
  • 17
  • 37
kikkpunk
  • 1,287
  • 5
  • 22
  • 34
  • I think you're actually looking for [How to generate javascript stacktrace?](http://stackoverflow.com/q/13480558/1048572) – Bergi Feb 02 '15 at 21:53
  • or https://stackoverflow.com/questions/1340872/how-to-get-javascript-caller-function-line-number-how-to-get-javascript-caller/3444831#3444831 – Bergi Feb 02 '15 at 21:55

0 Answers0