Q:

Learn about a javascript object

I have an [object Object] being passed as an argument through a jQuery function and I want to learn more about it.  I don't want to know anything about this specific situation (unless there is no solution) but how to replicate something like php's var_dump().

A:

You could use console.log(your_object_instance); and look in the FireBug console in FireFox. This also works with Chrome/Safari developers tools. You will learn everything you need about this object such as properties, methods, ...

A:

function odump(object, depth, max){
  depth = depth || 0;
  max = max || 2;

  if (depth > max)
    return false;

  var indent = "";
  for (var i = 0; i < depth; i++)
    indent += "  ";

  var output = "";  
  for (var key in object){
    output += "\n" + indent + key + ": ";
    switch (typeof object[key]){
      case "object": output += odump(object[key], depth + 1, max); break;
      case "function": output += "function"; break;
      default: output += object[key]; break;        
    }
  }
  return output;
}

