Log stack trace in JS
I often have to debug mobile devices etc. where using the debugger
statement isn't a viable option either because there's no way to observe the breakpoint or setting up a way to do it would be overly tedious.
Other times I might not want to break execution when the code point gets run often, but I want to see if there are any deviances in the call stack of that code point.
In these cases I've found that the easiest way to log the stack trace is to use the stack
attribute of an error, like this:
console.log( Error().stack );
Written by Jussi Kalliokoski
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Logging
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#