title: JavaScript if var exists
body: <p>I want my code so that if a specific var exists it will perform an action, else it will be ignored and move along. The problem with my code is, if the specific var does not exist it causes an error, presumably ignoring the remainder of the JavaScript code.</p>
  
  <p>Example</p>
  
  <pre><code>var YouTube=EpicKris;
  
  if ((typeof YouTube) != 'undefined' &amp;&amp; YouTube != null) {
      document.write('YouTube:' + YouTube);
  };
  </code></pre>