Javascript testing whether or not a variable is set

Viewed 22337

Generally, I test whether or not a variable is set with something like this:

if (variable !== '') {

   do something...

}

I know there are other methods for testing variables like typeof but I don't see any advantage - is this an appropriate way to test whether or not a variable is set? Are there problems with it that I should be aware of ?

5 Answers
Related