You can use this following code, if(typeof(foo) !== 'undefined' && foo != null) { //you can use foo!}
Joomla Web Design