Variables dump to Javascript console
The Drupal for Firebug module (which can be used with Chrome or Firefox) has a firep() function built in which will log a print_r of any variable passed to it into the Drupal for Firebug widget. That might be an option.

If you really want a console log, though, I think you'd have to write the functionality yourself. It isn't too hard though, here's a quick module I knocked up that works well for me:

File: js_debug.info

name = JS Debug
core = 7.x


File: js_debug.module

function js_debug_log($var = NULL) {
  $log = &amp;drupal_static(__FUNCTION__, array());

  if ($var) {
    $log[] = $var;
  }

  return $log;
}

function js_debug_page_alter(&amp;$page) {
  drupal_add_js(drupal_get_path('module', 'js_debug') . '/js_debug.js', 'file');
  drupal_add_js(array('js_debug' =&gt; array('messages' =&gt; js_debug_log())), 'setting');
}


File: js_debug.js

(function($) {
  $(function() {
    if (Drupal.settings.js_debug.messages) {
      for (var i = 0; i &lt; Drupal.settings.js_debug.messages.length; i++) {
        console.log(Drupal.settings.js_debug.messages[i]);
      }
    }
  });
})(jQuery);


The above code is obviously very bare, and doesn't check to make sure console.log() is available, etc. But it will work fine in Chrome/Firefox for any var (including arrays and objects).

To use, simply call js_debug_log($var); from code; the variable you pass will be logged in the console as you'd expect.