This can be different for the different platforms that you are currently working on. If you are running from terminal then you use print, if you dont have the console object then you can use document.write() and so on.
Here is something that you can use/read to understand:
var foo = {bar: "baz", boolean: true, num: 2}
for (i in foo) {
//checks to see where to print.
if (typeof console === 'object')
console.log(i + ": " + foo[i]);
else if (typeof document === 'object')
document.write(i + ": " + foo[i]);
else
print(i + ": " + foo[i]);
}
Alternatively, if you just say console.log(foo) in Chrome/Firefox, the browsers do the looping-highlighting for you and give you a pretty-print of your object, so you dont really need to do the looping shown above.
You can also use console.debug(foo) instead of console.log(foo), the difference is subtle. You can read more about this at http://getfirebug.com/wiki/index.php/Console_API