I am working in php and have a javascript file linked with 2 controllers. Now for one controller I declared a variable that is used by it. But when the second controller goes through it since there is no definition or declaration for it in that controller I get an error that the variable is not defined. I tried using the following statement in javascript to check for its existence or declaration/definition but still got the error. Secondly is this a good practice of using one javascript file for both the controllers? Statements I have tried so far:
if(variable){}
if(variable === null){}