You can do either one. Basically when you do it as if(object) it checks to see if anything exsits if the object exsists. I usually only do it when I am certain that the data stored in the variable/object is a boolean.
I usually use == true if I am writing a script for beginners since it is easier for them to understand.
Joined: Oct 14, 2004
Thanks for your prompt reply.
Re: "I usually only do it when I am certain that the data stored in the variable/object is a boolean."
Joined: Nov 08, 2001
it usually checks to see if the object exsists.
if(document.all) checks to see id the document all object exsists. It would return true for IE and false for Mozilla.
Running the following script can show you what problems can occur:
You might get the wrong results depending on what type of information you are looking at.