Created
February 3, 2016 01:47
-
-
Save ginsterbusch/33107b194d4bcfb67d14 to your computer and use it in GitHub Desktop.
console tricks compared
This file contains 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
// preparation | |
var foo = 'test', bar = false, hello = { 'world':{ 'silly':'buggers'} }; | |
// original base statement: | |
console.log('foo = ' + foo + ', bar = ' + bar); | |
// suggested version of http://makandracards.com/makandra/38271-useful-tricks-for-logging-debugging-information-to-the-browser-console | |
console.log('foo = %o, bar = %o', foo, bar); | |
// adjusted for hello | |
console.log('foo = %o, bar = %o, hello = %o', foo, bar, hello); | |
// my suggestion ( https://twitter.com/alltagsgrauen ) - less work and still achieves the same: | |
console.log('foo:', foo, 'bar:', bar, 'hello:', hello); | |
// slightly better readable version (just a nice-to-have): | |
console.log('foo:', foo, ', bar:', bar, ', hello:', hello); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment