Use %c
as a specficier to format with CSS style.
console.log(`%c${myText}`, 'color: red; background: black;');
Console groups can be nested.
console.group();
console.log();
// ...
console.groupEnd();
console.groupCollapsed();
console.log('something');
// ...
console.groupEnd();
console.log(arr); // yup, we all know this one!
console.dir(arr); // more JSON like output
console.table(arr); // table style output
console.info();
console.warn();
console.error();
Print out the functional call stack.
function funcA() {
console.trace();
}
Similar purpose as performance.now
console.time('funcA');
funcA();
console.timeEnd('funcA');
Monitor CPU profile of a certain function. This is super cool!
console.profile('funcA');
funcA();
console.profileEnd('funcA');