title: Can I have setInterval and setTimeout at the same time?
body: <p>According to this thread: <a href="https://stackoverflow.com/questions/2553138/how-many-javascript-settimeout-setinterval-call-can-be-set-simultaneously-in-on">how many javascript setTimeout/ setInterval call can be set simultaneously in one page?</a> it is possible to have multiple setIntervals at the sametime.</p>
  
  <p>However, is it possible to have a setInterval and setTimeout at the sametime?</p>
  
  <p>This is not working...</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"&gt;&lt;/script&gt; 
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      $(document).ready(function() {
          init();
      }); 
  
      function init() {
          $('#startbutton').on('click', handleClick);
      }
  &lt;/script&gt;   
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script&gt;
  
  var playBeep = function () {
  var snd = new Audio("beep-7.wav");
  snd.play();
  }
  
  var handleClick = function () {
      var interval1 = setInterval(updateDisplay, 1); 
      makeIntervals([1,2,3], playBeep);
  }
  
  var makeIntervals = function(timeList,callback){
  intervals = []
  for(i in timeList){
      intervals.push(setTimeout(callback,timeList[i]))
  }
  return intervals
  }
  
  function updateDisplay() {
      var value = parseInt($('#timer').find('.value').text(), 10);
      value++;
      $('#timer').find('.value').text(value);
  }
  
  &lt;/script&gt;
  &lt;button type="button" id="startbutton"&gt;Play Beep&lt;/button&gt;
  &lt;P&gt;
  &lt;div id="timer"&gt;&lt;span class="value"&gt;0&lt;/span&gt; ms&lt;/div&gt;
  &lt;P&gt;
  </code></pre>