• Skip to main content
  • Skip to footer

recoveryArea

Content Management for Everyone!

  • About me
  • Blog

A smarter console.info

9 February 2011 By Pascal Louwes

Here is a little piece of code you can use in your project for slightly smarter console messages. Objects and arrays are handled differently when logged to the console than strings. Firebug gives you a stringified version of the object while console.dir gives you an expandable object. Both give you the expandable object in Chrome. To work around this you can use this little snippet, it will always give you the correct version.

var debug = function(message) {
    "object" === typeof console && ("object" === typeof message || "array" === typeof message ? console.dir(message) : console.info(message));
};

Filed Under: JavaScript

Pascal Louwes

Me
Creative, resourceful and innovative Front End Developer / User Experience Optimizer. I love to make stuff work, perform and convert better.

Buzzwords
JavaScript, jQuery, User Experience & Conversion Optimization, Web Strategy, Interaction Design, Accessibility, Wordpress Design, Development & Optimization. check out my full profile

Footer

Office

recoveryArea
Nijverheidstraat 11-1
7511 JM Enschede
The Netherlands

KvK: 65594940

Mission

Building a more elegant, accessible internet through precise experimentation and performance engineering. Moving toward an empathic, sustainable future where technology genuinely serves people.

Read my full profile

Get in touch

  • GitHub
  • LinkedIn
  • Twitter

Copyright © 2026 · From recoveryArea with