Basically you have two comfortable options.
console.log
- Chrome and Firefox allow string substituting and formatting with "%O" contained in the first parameter for
console.log
.
- Chrome and Firefox allow string substituting and formatting with "%O" contained in the first parameter for
console.dir
Using your example object,
var obj = {name:"agstudy",job:"developer"};
console.log ("Formatted object %O",obj)
console.dir (obj);
this looks like this
- Chrome
console.log
console.dir
- Firefox (using firebug)
console.log
console.dir
- ... IE flaws
Here is a Fiddle as well.
If you are looking for a way to print your objects directly in a Fiddle site, taking a look at JSBin, which provides a built-in console, is worth it.