Skip to content

Instantly share code, notes, and snippets.

@givingwu
Forked from IUnknown68/colorBrowserConsole.js
Created September 19, 2018 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save givingwu/70708c08f1461ea793cec6e91d2770d4 to your computer and use it in GitHub Desktop.
Save givingwu/70708c08f1461ea793cec6e91d2770d4 to your computer and use it in GitHub Desktop.
Adds color functions to the browser-console (e.g. console.green() or console.greenB() for bold-green. Simple and primitive.
(() => {
['white', 'silver', 'gray', 'black', 'red', 'maroon', 'yellow', 'olive', 'lime',
'green', 'aqua', 'teal', 'blue', 'navy', 'fuchsia', 'purple'
].forEach(color => {
console[color] = (...args) => {
console.log(`%c${args.join(' ')}`, `color:${color}`)
}
console[`${color}B`] = (...args) => {
console.log(`%c${args.join(' ')}`, `color:${color};font-weight:bold`)
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment