title: Declare such Function if it does not exist
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8839112/if-function-does-not-exist-write-function-javascript">if function does not exist write function - javascript</a>  </p>
  </blockquote>
  
  
  
  <p>I have a situation when some function X is being called. After some postbacks this function is no longer declared, but still being called by  the code, obviously i get js error saying <code>X is not defined</code> . (call it a bug if you wish) but
  It is not under my control to not call it or to change the calling functionality. </p>
  
  <p>What I would like to do is a fail safe that will declare such function if it does not exist. So the logic is:</p>
  
  <p>If function not declared then declare one.</p>
  
  <p>Is that possible in javascript i.e. to declare/register a function dynamically in global scope? </p>
  
  <p>Thanks.</p>