ONYX ONYX - 2 days ago 5x
Javascript Question

console.log showing contents of array object

I have tried using console.log so I can see the content of my array that contains multiple objects. However I get an error saying console.log is not an object etc. Im using jquery 1.6.2 and my array is like this:

filters = {dvals:[{'brand':'1', 'count':'1'},
{'brand':'2', 'count':'2'},
{'brand':'3', 'count':'3'}]}


What I want to to do is write out the contents of the array(filters) to a alert box (thats what I thought console.log did) in the filters format. How do I do that?


console.log does not produce any message box. I don't think it is available in any version of IE (nor Firefox) without the addition of firebug or some equivalent.

It is however available in Safari and Chrome. Since you mention Chrome I'll use that for my example.

You'll need to open your window and its developer window counterpart. you can do this by right clicking any element on the page and selecting "Inspect element". your window will be divided in two parts, the developer part being the bottom. in the division between the two parts is a bar with buttons and the rightmost button there is labeled "console". You'll need to click that to switch to the console tab. Unfortunately, I don't know how to get there by keyboard in chrome. (In Safari on Mac OS X it's command + shift + I)

Once there, you will be able to interact with whatever page is loaded on top through javascript from that console, and any messages you console.log will be displayed there.