DEV Community

Liz Lam
Liz Lam

Posted on

6 2

Output to the Console, with Feeling

Most of us are familiar with using console.log to debug our JavaScript code. For those who are not familiar, console.log() simply logs messages to the console.

Alt Text

Did you know there are other levels of messaging that can be sent to the browser's console? These levels let us convey the sentiment of a message in addition to the content of the text. They are kind of like the emojis of the console.

Possibly more appropriate than console.log(), use console.debug() for debugging messages (or notes to yourself).

Alt Text

If you want to gently warn someone with a yellow alert message, use console.warn().

Alt Text

For more severe "code red" situations, use console.error().

Alt Text

If you just want to stoicly pass on some information, use console.info().

Alt Text

With these different options, it is easy to convey the types of messages sent to the console as well as filter on them.

NOTE: I'm using FireFox with the dark theme on the web console.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (2)

Collapse
 
devdrake0 profile image
Si

Most of us are familiar with using console.log to debug our JavaScript code.

I'm hoping the majority aren't still using console.log to debug their code 😄

Collapse
 
grepliz profile image
Liz Lam

I think it's used probably more often than people like to admit. ;)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

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

Okay