title: Infinite Timer Loop with javascript ( no setInterval)?
body: <p>I was asked (by a friend) to build a timer (infinite one which writes a line every second), but without <code>setInterval</code>.</p>
  
  <p>I <a href="http://jsbin.com/ukohoj/5/edit" rel="noreferrer">solved</a> it with : </p>
  
  <pre><code>var i = 0;
  
      function k(myId, cb)
      {
          setTimeout(function ()
          {
              console.log(myId);
              cb();
          }, 1000);
      }
  
      function go()
      {
          i++;
          k(i, go);
      }
  
      go();
  </code></pre>
  
  <p>And it is working.</p>
  
  <p>The problem is that I'm afraid there's gonna be a memory pressure.  It actually creates a recursion and after a while (week or something) - the process will consume much memory. (the stack is never deallocated)</p>
  
  <p>How can I change my code in order not to be much memory consume?</p>