title: Run a Function For Each Milliseconds
body: <p>I am trying to run a function for each milliseconds, In order to achieve so, I just preferred <code>setInterval</code> concept in javascript. My code is given below,</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div id=test&gt;0.0&lt;/div&gt;
  </code></pre>
  
  <p><strong>Script:</strong></p>
  
  <pre><code>var xVal = 0;
  var xElement = null;
  
  xElement = document.getElementById("test");
  var Interval = window.setInterval(startWatch, 1);
  
  
  function startWatch(){
  
      xVal += 1;
      xElement.innerHTML = xVal;
  
  }
  </code></pre>
  
  <p>so the above code is working fine. But while I am testing the result with a real clock, the real clock requires 1000 milliseconds to complete 1 second, at the same time the result require more than 1000 milliseconds to complete a second.</p>
  
  <p><strong><a href="http://jsfiddle.net/3hEs4/" rel="noreferrer">DEMO</a></strong></p>
  
  <p>Can anybody tell me,</p>
  
  <p>Is there any mistakes with my code? If yes then tell me, How to display milliseconds accurately.?</p>