Skip to content

Instantly share code, notes, and snippets.

@ginsterbusch
Created February 3, 2016 01:47
Show Gist options
  • Save ginsterbusch/33107b194d4bcfb67d14 to your computer and use it in GitHub Desktop.
Save ginsterbusch/33107b194d4bcfb67d14 to your computer and use it in GitHub Desktop.
console tricks compared
// 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