Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show full object in Chrome console?

People also ask

How do I show objects in console?

Answer: Use console. log() or JSON. stringify() Method You can use the console. log() method, if you simply wants to know what's inside an object for debugging purpose. This method will print the object in browser console.

How do I show all variables in console?

Open the console and then enter: keys(window) to see variables. dir(window) to see objects.

How do I make a pretty print console in chrome?

If it's the Sources panel, you can manually enable or disable pretty-printing by clicking Format. In general, if you see that icon anywhere, clicking it will enable or disable pretty-printing. Show activity on this post. I just did the same thing because of the really poor UI there.

How do you show variables in inspect element?

To inspect local variable values While running in Debug mode, double-click any variable that appears in the Local Variables window. This displays the Debug Inspector for that local variable. Inspect the variable's value. Change the value by clicking the button with an ellipsis (...) on it.


Use console.dir() to output a browse-able object you can click through instead of the .toString() version, like this:

console.dir(functor);

Prints a JavaScript representation of the specified object. If the object being logged is an HTML element, then the properties of its DOM representation are printed [1]


[1] https://developers.google.com/web/tools/chrome-devtools/debug/console/console-reference#dir


You might get better results if you try:

console.log(JSON.stringify(functor));

You might get even better results if you try:

console.log(JSON.stringify(obj, null, 4));

var gandalf = {
  "real name": "Gandalf",
  "age (est)": 11000,
  "race": "Maia",
  "haveRetirementPlan": true,
  "aliases": [
    "Greyhame",
    "Stormcrow",
    "Mithrandir",
    "Gandalf the Grey",
    "Gandalf the White"
  ]
};
//to console log object, we cannot use console.log("Object gandalf: " + gandalf);
console.log("Object gandalf: ");
//this will show object gandalf ONLY in Google Chrome NOT in IE
console.log(gandalf);
//this will show object gandalf IN ALL BROWSERS!
console.log(JSON.stringify(gandalf));
//this will show object gandalf IN ALL BROWSERS! with beautiful indent
console.log(JSON.stringify(gandalf, null, 4));

this worked perfectly for me:

for(a in array)console.log(array[a])

you can extract any array created in console for find/replace cleanup and posterior usage of this data extracted


I made a function of the Trident D'Gao answer.

function print(obj) {
  console.log(JSON.stringify(obj, null, 4));
}

How to use it

print(obj);