Skip to content

Instantly share code, notes, and snippets.

@katsimoto
Created June 23, 2022 01:20
Show Gist options
  • Select an option

  • Save katsimoto/57961eded3ab31601f042a95e703f13e to your computer and use it in GitHub Desktop.

Select an option

Save katsimoto/57961eded3ab31601f042a95e703f13e to your computer and use it in GitHub Desktop.

Revisions

  1. katsimoto created this gist Jun 23, 2022.
    23 changes: 23 additions & 0 deletions index.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    // https://towardsdev.com/console-log-and-his-ninja-pals-4fc0863ad5f4

    // The count method can be used to display the number of times this message was shown on screen.
    console.count(label);

    // Instead of opening each and looking into them, we can have a flat tabular representation.
    console.table([
    { column1: 'row1', column2: 'row1' },
    { column1: 'row2', column2: 'row2' },
    ]);

    // A quick and dirty way to measure the performance of your javascript code.
    console.time(label);
    ...
    console.timeEnd(label);

    // When things get serious, you may need to solve the chicken-egg problem, ie, which method was called first.
    console.trace();

    // Sometimes it's not worth logging every time. Maybe say, we are tracking
    // mouse movement and need a message if the mouse cursor moves outside a box.
    console.assert(condition, label, value)