Last active
September 2, 2017 15:16
-
-
Save arturparkhisenko/889150f8b4d25756afa2 to your computer and use it in GitHub Desktop.
console.log tips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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