JavaScript breaking even when I test if a variable exists
<p>When PHP is building HTML document, I add to it a code <code>var myVariable = 'somedata';</code>, which is used by a .js file. Of course, that file's code must be prepared for that variable not being set.</p>

<p>Doing some tests, I see that if I don't set the variable in HTML, Firebug console reports <code>myVariable is not defined</code>, and the code breaks: everything that should be run after the call to the function that uses that variable, doesn't run at all.</p>

<p>Only that function requires that variable, so I want the it to nicely return instead of breaking, so I used <code>if(undefined === myVariable) return;</code>, but it didn't work. Console still reports that error, and JS still breaks.</p>

<p>What's the best practice for testing if a variable is defined before using it?</p>
