lovespring lovespring - 4 months ago 19
Javascript Question

How to show full object in Chrome console?

var functor=function(){
//test
}

functor.prop=1;

console.log(functor);


this only show the function part of the functor, cannot show the properties of the functor in console.

Answer

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

Comments