Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  51] [ 1]  / answers: 1 / hits: 31382  / 11 Years ago, mon, july 29, 2013, 12:00:00

Im getting my objects returned in the console as [object Object], however which way I try to have it log all of the contents of the objects I get nothing or errors. I've read a whole lot of questions on SO about this (e.g.: this, this, this, this and this) but still can't figure it out.



I've created some objects by looping through JSON array's using:



var tables = {};

$.each(campaigns, function(key, value){
tables[value] = '';
var entries = [];
$.each(data, function(k, v){
if(v.campaign == value){
entries.push(v);
}
});
$.extend(tables[value], entries);
});

console.log('tables: ' + tables);


The amount of objects is correct based on the number of objects returned with different conditions and parameters. However, I would like to see what's actually inside them! I don't want to include all sorts of external scripts, do weird and unnecessary loopy-loops, just some simple command I'm overlooking would be awesome!



How to go about logging objects with something like console.log(someObj);?


More From » jquery

 Answers
183

Try JSON.stringify()



console.log('tables: ' + JSON.stringify(tables));


or in FF and Chrome



console.log('tables: ', tables);

[#76681] Saturday, July 27, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kayden

Total Points: 546
Total Questions: 102
Total Answers: 95

Location: Virgin Islands (U.S.)
Member since Fri, Mar 4, 2022
2 Years ago
;