๐—ฆ๐˜๐—ผ๐—ฝ ๐—จ๐˜€๐—ถ๐—ป๐—ด c๐—ผ๐—ป๐˜€๐—ผ๐—น๐—ฒ.๐—น๐—ผ๐—ด() ๐—ณ๐—ผ๐—ฟ ๐——๐—ฒ๐—ฏ๐˜‚๐—ด๐—ด๐—ถ๐—ป๐—ด, instead use c๐—ผ๐—ป๐˜€๐—ผ๐—น๐—ฒ.table()

Untill now I was also using console.log() for debugging purposes, But here’s why you should switch to console.table()

  • Better Visualization
  • Faster Debugging
  • Professional Presentation
  • Selective Insights

Better Visualization
console.log() dumps raw objects or arrays, which can be hard to read.
vs
console.table() organizes data into a structured table format with headers and rows, making it much more human-friendly.

Faster Debugging
In complex datasets, like arrays of objects, console.table() makes it easy to spot trends, errors, or missing data at a glance.

Professional Presentation
Data in a table looks polished, ideal for demos or explaining issues to others.

Selective Insights
Focus on specific columns by passing a list of keys
(e.g., console.table(data, ['key1', 'key2'])).

I’m a huge fan of Cricket and someday may be I get a opportunity working on a Cricket app, but until then let’s just try some test Cricket data.

Example: Cricket Team Debugging

const cricketTeams = [
  { team: 'Pakistan', matches: 25, wins: 20, losses: 5 },
  { team: 'India', matches: 25, wins: 18, losses: 7 },
  { team: 'Australia', matches: 20, wins: 14, losses: 6 },
  { team: 'England', matches: 22, wins: 12, losses: 10 }
];

// Debugging with console.log()
console.log(cricketTeams);

// Debugging with console.table()
console.table(cricketTeams);

Output1: console.log


Output2: console.table(cricketTeams)


Output3: console.table(cricketTeams, [‘team’, ‘wins’]);
You can focus on specific columns by passing an array of keys as a second argument.


In both outputs, console.table() makes it easier to interpret the data than a plain console.log().

When to use console.table()?
– When dealing with arrays of objects, JSON-like data, or complex structures.
– For a quick visual check during debugging or development.
– To showcase structured data in a presentation or demo.

Limitations of console.table()
– Best suited for small to medium-sized datasets; large datasets might not render well in the console.
– Not all console environments (e.g., certain Node.js versions) support it fully.

Why It Matters?
console.log() is fine for basic debugging, but for complex or structured data, console.table() is a game-changer. It’s cleaner, faster, and makes debugging more efficient.

Author: Danyal
I'm a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.