Skip to content

Instantly share code, notes, and snippets.

@arturparkhisenko
Last active September 2, 2017 15:16
Show Gist options
  • Save arturparkhisenko/889150f8b4d25756afa2 to your computer and use it in GitHub Desktop.
Save arturparkhisenko/889150f8b4d25756afa2 to your computer and use it in GitHub Desktop.
console.log tips
//good article about some tips http://css.yoksel.ru/funny-little-console/
//https://stackoverflow.com/questions/7505623/colors-in-javascript-console/21457293
//In Chrome & Firefox (+31) you can add CSS in console.log messages:
console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');
console.log('%c%s', 'color: red; background: yellow; font-size: 24px;', 'WARNING!');
//normal output:
console.log ( 'String:', {a: 'object, or any kind of type here'}, ['and you can use it like args'] );
//formatted output:
- %s — string
- %d or %i — number (digit, integer)
- %f — floating-point number
- %o — like dom element
- %O — like js object
- %c — styled by css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment