Got confused by this behaviour. I thought doing something like:
if (variable name)
{
... do this...
}
should work. However if the variable is not defined, I just get 'ReferenceError: Can't find variable: "variable name, and the else block won't even be executed. For example the following snippet that I got off another StackOverflow question doesn't work when I test it. Any suggestions?
if(persons_name)
{
var name = persons_name;
}
else
{
var name = "John Doe";
}