Today I Learned

hashrocket A Hashrocket project

Group together console logs

In Javascript you can group together console logs by using console.group()

This will output all of the following console logs in a nicer indented form.

console.group("Food");
console.log("Apple");
console.log("Banana");
console.log("Cookie");

image

You can nest groups inside of one another. To end a group just call console.groupEnd()

// ✨ indented for a better visual experience ✨
console.group("Food");
  console.group("Fruit");
    console.log("Apple");
    console.log("Banana");
  console.groupEnd();
  console.group("Dessert");
    console.log("Cookies");
  console.groupEnd();
console.groupEnd();

image

See More #javascript TILs
Looking for help? At Hashrocket, our JavaScript experts launch scalable, performant apps on the Web, Android and iOS. Contact us and find out how we can help you.