title: Hello, i am working with javascript and i was wondering if there is an event listener for passing time, e.g. a timer
body: <p>i am working with javascript and i was wondering if there is an event listener for passing time, e.g. a timer. I currently have an event listener in place for a mouse click, but i would like to remove the ability for GUI to control when the event happens.</p>
  <p>I have this code right now for the event listener.</p>
  <pre><code>function doubleClick(e) {
      for (var i = gravities.length - 1; i &gt;= 0; i--) {
          if (gravities[i].isMouseOver) {
              gravities[i].collapse();
              break;
          }
      }
  }
  </code></pre>
  <p>I am relatively new at javascript, and don’t know how to make another line of code that would execute the function, but on a timed schedule i.e. every 30 seconds as opposed to on user input.</p>