Can Chrome's built-in JavaScript console display colors?
I want errors in red, warnings in orange and console.log
's in green. Is that possible?
As a simple example, we can make the log message orange. console. log("%cLog Message", "color: orange"); You might notice that %c will inject the CSS styles specified in the second argument into that location.
The JavaScript console is a command line interface in your browser that can execute snippets of code. When that code snippet is designed to interact with the webpage you are currently on, result can happen that might not have been possible otherwise.
dir() The method console. dir() displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.
In Chrome & Firefox (+31) you can add CSS in console.log
messages:
console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');
The same can be applied for adding multiple CSS to same command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With