title: Performance of recursive function of time
body: <p>I have a <code>function startTime()</code> that handles a clock showed on the page, and the last line of this function is <code>var t = setTimeout(function(){ startTime() }, 1000);</code>.</p>
  
  <p>Being a recursive function with a timeout, what are the implications in performance? Does it consumes more and more memory as time passes by? I mean, if I leave this page opened during one day, and compare it to being open for a week, what are the difference? If this approach is not so good, is there a better one to this? Also, feel free to give some tips to my code (standards and better typing). </p>
  
  <p>Thanks!</p>
  
  <p>Complete code:</p>
  
  <pre><code>function startTime() {
      var today = new Date();
      var h = today.getHours();
      var m = today.getMinutes();
      var s = today.getSeconds();
  
      // function checkTime(): add a zero in front of numbers&lt;10
      h = checkTime(h);
      m = checkTime(m);
      s = checkTime(s);
      var t_hora = h + ":" + m;
      document.getElementById("clock").innerHTML = t_hour + ":" + s;
      if (s%20 &lt;= 10) {
        document.title = t_hour;
      } else {
      document.title = "My customized title";
    }
    var t = setTimeout(function(){ startTime() }, 1000);
  }
  
  function checkTime(i) {
    if (i &lt; 10) {
      i = "0" + i;
    }
  return i;
  }
  </code></pre>