Logging Enumerable Data With Javascript | Task

Ole Ersoy
Jan - 22  -  1 min

Scenario

We have a Todo class:

class Todo {
  constructor(
    public id: string,
    public label: string,
    public description: string
  ) {}
}

And we we want to log instances in table format.

Approach

const t = new Todo('1', 'Completed', "You've completed me!");

console.table(t);

The instance is is logged with property names appearing in the first column and values in the second.

Demo