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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With