How to print out variables in Javascript for debugging

I'm pretty new to Javascript but I do have a programming background.
I have a script from a book (on Ajax) that doesn't work, which isn't much of a surprise since half the scripts in this books source code don't work (Ajax for Dummies).

Anyway, I'm printing out variables using an alert statement but when I get to the statement below the message I get back is "[objectHTMLCollection]".  Can someone tell me how I can print out the contents of that object?

-- Snip --
options = xmlDocument.getElementsByTagName("option");


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

var options = xmlDocument.getElementsByTagName("option");
      for(var i=0,limit=options.length; i < limit; ++i)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
b0lsc0ttIT ManagerCommented:

If you want just one alert then try ...

if(options) alert(options.join("\n"));

I kept Hielo's if there since that will probably help this script.  Credit to him for that suggestion.  Mine is just a little different since it puts the array in a string separated by a new line.

Let me know if you have any questions or need more information.

michaelshavelAuthor Commented:
Thank you both!
b0lsc0ttIT ManagerCommented:
Your welcome!  I'm glad I could assist.  Thanks for the grade, the points and the fun question.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.