Skip to content

Instantly share code, notes, and snippets.

@katsimoto
Created June 23, 2022 01:20
Show Gist options
  • Save katsimoto/57961eded3ab31601f042a95e703f13e to your computer and use it in GitHub Desktop.
Save katsimoto/57961eded3ab31601f042a95e703f13e to your computer and use it in GitHub Desktop.
Console methods
// 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment