Often times in JS it is necessary to trace through someone else’s code (or your own 😉 ) to determine the root of a problem. Many times I have found that knowing how a function was called in the first place can be very helpful. Since I use Chrome for development, as i’m sure many others do, I thought it appropriate to point out that you can show the stack trace whenever you want in the console by adding the following snippet to your code:

console.log('Stack trace:', (new Error).stack);

For those who need similar functionality in other browsers, I did a quick Google search and found stacktrace.js. Happy coding! 😎

Categories: BlogJavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *