title: if function does not exist write function - javascript
body: <p>In php I'm writing the following</p>
  
  <pre><code>&lt;?php
  if(x != 0) {
  echo "function myfunction(){};";    
  }
  ?&gt;
  </code></pre>
  
  <p>In javascript I wish to test if the function exists and if not write out an empty function</p>
  
  <pre><code>if(typeof myfunction != 'function'){
      function myfunction(){};
  }
  </code></pre>
  
  <p>This works great in firefox but, in chrome even if the typeof equals function it still goes into and creates the empty function.  I can't find a work around for chrome, i've tried if(!myfunction), if(typeof window.myfunction != 'function) but nothing seems to work here for chrome when everything seems to work in firefox.  Any ideas?</p>