You can use special formatters in the console.log function to format logs just the way you want.
- Use
%sto format a variable as a string. - Use
%dto format a variable as an integer. - Use
%fto format a variable as a float. - Use
%oto print a DOM element variable. - Use
%Oto print an object variable.
As a bonus, the %c formatter can also be used to style console messages with CSS properties!
var el = document.body;
console.log('%c There are %d elements in %O', 'color:lime;background:black;', el.childElementCount, el);
