console.log
Shows general values during development.
The console is your first debugging instrument: it shows values, warnings, errors, tables, timings and groups while code runs.
console.group("Checkout");
console.log("Subtotal", 120);
console.warn("Coupon expired");
console.groupEnd();
JavaScript Basics
Every browser has developer tools, and the Console panel is usually the fastest way to inspect what JavaScript is doing.
console.log is the familiar starting point, but the console has more: warn, error, table, group, time and trace can make debugging much clearer.
The important discipline is knowing when to remove or reduce logs. A useful debug log in development can become noisy or risky in production.
Shows general values during development.
Marks something suspicious that does not stop the program.
Marks an error or failed operation clearly.
Displays arrays and objects in a table for easier scanning.
Examples
const users = [
{ name: "User A", tasks: 12 },
{ name: "User B", tasks: 18 },
];
console.group("User activity");
console.table(users);
console.log("Total users:", users.length);
console.groupEnd();
console.log("test");
console.log(user);
console.log(password);
console.log("why is this broken????");
Rules that matter
JavaScript becomes much easier when you understand why a pattern exists. The syntax is only the surface; the real skill is choosing the right behavior for the interface.
console.log("total", total) is clearer than console.log(total).
Warnings, errors, tables and groups communicate intent better than endless log lines.
Passwords, tokens, session data and private user information do not belong in the console.
Keep intentional diagnostics, remove random development noise.
console.time and console.timeEnd can expose slow blocks quickly.
The console is powerful, but DevTools breakpoints are often better for step-by-step debugging.
Production thinking
Debugging is part of programming. The console gives you direct feedback, so you can understand reality instead of guessing from the code in your head.
Console messages do nothing for users. If a user needs feedback, put it in the interface with readable text and appropriate live regions when needed.
Production logging should be intentional, privacy-aware and ideally connected to real monitoring for errors that matter.
Console errors can reveal broken scripts that affect rendering, navigation and user behavior. Search crawlers will not fix broken JavaScript for you.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read the topic. Change the code, explain what happened and answer the questions in your own words.