This question already has an answer here: Detecting an undefined ... If you are interested in finding out whether a variable has been declared ...
stackoverflow.com