function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fred13Fred13 

Using Console in chrome to view variable contents

I am wondering if there is a way to view a variables contents in the console in chrome?  I am using the following line of code in my controller:

console.log('here is group structure list' + component.get("v.groupstructureList"));

When I look at the results in the console, I only see:

here is group structure list[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Is there a way to see the real contents of the variable?

thanks!!

Fred
Mario PariseMario Parise
I would try:
console.log( 'here is group structure list:' );
console.table( component.get("v.groupstructureList") );
Failing that, you might try...
console.log( 'here is group structure list:' );
for (var x in component.get("v.groupstructureList") ) {
    console.table( x );
}
...which would in theory attempt to individually log out each one of the objects in your list.
Fred13Fred13
Thanks for responding Mario.  Neither of those worked for me.  However, I did find that entering debugger; stops the code and then allows me to see the contents of the variables.  thanks again!
Raj VakatiRaj Vakati
try this
 
console.log(JSON.parse(JSON.stringify(component.get("v.groupstructureList") )));
                console.log(JSON.stringify(component.get("v.groupstructureList") , null, 4))

 
Fred13Fred13
Unfortunately, that did not work either.  But I appreciate the reply!

Fred