Skip to main content

Command Palette

Search for a command to run...

Console.trace in JavaScript

Published
•1 min read•View as Markdown
Console.trace in JavaScript
J

I am a Senior Software Engineer. Google Developers Expert. Entrepreneur. Mountain Climber. Neil Diamond fanatic. Cat lover. Gardener. World traveler.

In yesterday's article, I showed you two ways to format your output to the console in JavaScript. If you have not read it, check it out here.

Today I wanted to show you another console command: console.trace().

console.trace()

The console.trace() method outputs a stack trace to the Web console.

Here is an example of how to use this:

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

foo();

In the console, the following trace will be displayed:

bar
foo
<anonymous>

Let's Connect

Thanks for reading my article today. If you like my content, please consider buying me a coffee ☕.

More from this blog

All Things Tech

75 posts

I am a Senior Software Engineer. Google Developers Expert. Entrepreneur. Mountain Climber. Neil Diamond fanatic. Cat lover. Gardener. World traveler.