Console.log() and Basic Output Methods
You'll learn how to use different console methods to categorize and filter your debugging messages by severity.
What You've Been Doing
You've already used console.log() countless times to print values and debug your code. It's the go-to tool for seeing what's happening inside your JavaScript. But the Console API offers more than just log() — it provides specialized methods that help you categorize messages by importance.
The Four Essential Console Methods
Think of these methods like notification severity levels on your phone:
console.log()— Standard information (like regular text messages)console.info()— Informational updates (like app notifications)console.warn()— Warnings that deserve attention (like low battery alerts)console.error()— Critical problems (like system errors)
Why Use Different Methods?
Each method displays differently in DevTools:
console.log()andconsole.info()appear as plain textconsole.warn()shows with a yellow warning icon and backgroundconsole.error()appears in red with an error icon and includes a stack trace
More importantly, DevTools lets you filter by message type. When debugging a complex application with hundreds of console messages, you can click the "Errors" filter to see only console.error() calls, or "Warnings" to focus on console.warn() messages.
Practical Usage
Use console.error() for exceptions or failed operations, console.warn() for deprecated features or potential issues, console.info() for general status updates, and console.log() for everyday debugging output. This semantic approach makes scanning console output far more efficient during development.
Key Takeaway: Use console.log(), info(), warn(), and error() to categorize your debug messages by severity, making them easier to filter and prioritize in DevTools.