title: Javascript setInterval function to clear itself?
body: <pre><code>myInterval = setInterval(function(){
       MyFunction();
  },50);
  
  function MyFunction()
  {
      //Can I call clearInterval(myInterval); in here?
  }
  </code></pre>
  
  <p>The interval's not stopping (not being cleared), if what I've coded above is fine then it'll help me look elsewhere for what's causing the problem. Thanks.</p>
  
  <p>EDIT: Let's assume it completes a few intervals before clearInterval is called which removes the need for setTimeout.</p>