title: Differences between these two throttle implementations
body: <p>Approach one:</p>
  <pre><code>function throttle(func, timeMs) {
    let lastTime = 0;
    return function() {
        const now = new Date();
        if (now - lastTime &gt;= timeMs) {
            func();
            lastTime = now;
        }
    };
  }
  </code></pre>
  <p>Approach two:</p>
  <pre><code>function throttle(func, timeMs) {
      let waiting = false;
      return function() {
          if (!waiting) {
              func();
              waiting = true;
              setTimeout(() =&gt; {
                  waiting = false;
              }, timeMs);
          }
      }
  }
  </code></pre>
  <p>One uses the timestamp to keep track of the call while the other uses timeout. Is one better than the other?</p>