MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Using console.log()0%
Study Materials
JavaScript for BeginnersProgress 0%
1.1What is JavaScript?1.2How JavaScript Works in Browser1.3Setting up Environment: VSCode, Live Server
11.1Using console.log()11.2Common Errors and Fixes11.3Clean Code Practices
HomeTutorialsJavaScript for BeginnersUsing console.log()
Common Errors and Fixes

Using console.log()

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study Materials

The browser console is the developer's primary diagnostic command center. Beyond basic text output with console.log(), the console object provides powerful methods for inspecting complex data, measuring performance, formatting tabular data, and tracing call stacks.


1. The Console Toolkit

Open your browser's console (F12 or Ctrl + Shift + I):

1// 1. Standard Informational Log:
2console.log("Application started successfully.");
3 
4// 2. Warning message (Yellow highlight with warning icon):
5console.warn("API token is nearing expiration.");
6 
7// 3. Error message (Red highlight with full stack trace):
8console.error("Failed to connect to database!");
9 
10// 4. Formatted Table View (Invaluable for arrays and objects!):
11const students = [
12 { id: 1, name: "Sumit", marks: 95 },
13 { id: 2, name: "Neha", marks: 98 },
14 { id: 3, name: "Aarav", marks: 88 }
15];
16console.table(students);

2. Timing Execution Performance: console.time()

To measure how many milliseconds an algorithm or loop takes to execute:

1console.time("ArraySortBenchmark");
2 
3const numbers = Array.from({ length: 100000 }, () => Math.random());
4numbers.sort();
5 
6console.timeEnd("ArraySortBenchmark");
7// Output: ArraySortBenchmark: 42.15ms

3. Grouping Logs: console.group()

Keep complex diagnostic logs organized:

1console.group("User Authentication Flow");
2console.log("Checking credentials in cache...");
3console.log("Validating session token...");
4console.log("User authorized as Admin.");
5console.groupEnd();

4. Setting Breakpoints in Browser DevTools

While console.log() is great for quick checks, modern developers use Breakpoints:

  1. 1
    Open Chrome DevTools -> Go to the Sources tab.
  2. 2
    Find your app.js file.
  3. 3
    Click on any line number in the gutter to set a blue breakpoint marker!
  4. 4
    Trigger the action on your page: the browser will pause execution in real time!
  5. 5
    Hover over variables to inspect their live values, view the Call Stack, and step through code line-by-line using F10 (Step Over) or F11 (Step Into).

Triggering Breakpoints in Code:

1function calculateDiscount(price) {
2 debugger; // Browser will automatically pause here if DevTools is open!
3 return price * 0.8;
4}

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What method formats and renders arrays of objects as a clean, sortable visual table in the browser console?
Question 2
Which console methods are paired together to measure the elapsed execution time of a code block?
Question 3
What happens when the browser encounters the debugger; statement while DevTools is open?
Question 4
Which console method displays a warning with a yellow background and warning icon?
Question 5
Why is relying solely on console.log for debugging discouraged in production enterprise applications?
Next Lesson

Common Errors and Fixes

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Handling Events: click, input, submitCommon Errors and Fixes

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master JavaScript for Beginners with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext