DEV Community

Cover image for Console.trace in JavaScript
Jennifer Bland
Jennifer Bland

Posted on • Originally published at jenniferbland.com

1

Console.trace in JavaScript

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();
Enter fullscreen mode Exit fullscreen mode

In the console, the following trace will be displayed:

bar
foo
<anonymous>
Enter fullscreen mode Exit fullscreen mode

Let's Connect

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

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay