Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
118
rated 0 times [  124] [ 6]  / answers: 1 / hits: 23079  / 8 Years ago, thu, july 14, 2016, 12:00:00

I have a newbie question. How do i print this info in the console?
the object shown in the console
I have an object that is not a DOM element and it has an array inside.
I print the object but I need to get the elements of the array.



How do I print the children of bannerdata?



I wrote: console.log(varName.bannerdata);



That is as far as i get.


More From » javascript

 Answers
14

Just click the little Arrow next to your object item, item in array will expand and you will get the properties for object stored in the array.



Or use JSON.stringify(yourArrayHere) as @trincot suggested, example:





var bannerData = [{item:1},{item:2},{item:3}];
console.log(JSON.stringify(bannerData));





JSON.stringify() method will convert a JavaScript value/object to a JSON string.



If you are interested in learning more about Chrome Developer tools including use of API console.log() and other tricks, you can start by reading the following:



https://developers.google.com/web/tools/chrome-devtools/



http://tutorialzine.com/2015/03/15-must-know-chrome-devtools-tips-tricks/


[#61364] Wednesday, July 13, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ezequiel

Total Points: 67
Total Questions: 96
Total Answers: 119

Location: Marshall Islands
Member since Tue, Sep 21, 2021
3 Years ago
;