Skip to content

Console.log and more

console.log

You don't need to concatenate values

const name = "Jean";
-console.log('name: ' + name); // DON'T
+console.log('name:', name); // DO

console.count([label])

function MyComponent(props) {
    console.count('Rendering...');
    ...
}
Rendering: 1
Rendering: 2
Rendering: 3
Rendering: n

console.table(data [, columns])

const elements = ['H', 'He', 'Li']
console.table(elements)
(index) Values
0 "H"
1 "He"
2 "Li"
const elements = [
  {
    number: 1,
    symbol: "H",
    name: "Hydrogen",
  },
  {
    number: 2,
    symbol: "He",
    name: "Helium",
  }
 ]
console.table(elements[0])
(index) Value
number 1
symbol "H"
name "Hydrogen
console.table(elements)
(index) number symbol name
0 1 "H" Hydrogen
1 2 "He" Helium
console.table(elements, ["number", "name"])
(index) number name
0 1 Hydrogen
1 2 Helium

Source: https://developer.mozilla.org/en-US/docs/Web/API/Console


Last update: July 14, 2020