title: Generating a unique ID in javascript. Understanding this code
body: <p>Here is a code snippet i've come across for creating uniqueIDs in a script.</p>
  
  <pre><code>var now = (new Date()).valueOf();
  var future = (new Date()).valueOf();
  while(future == now){
      future = (new Date()).valueOf();
  }
  return future;
  </code></pre>
  
  <p>My question is, why use <code>.valueOf()</code> instead of <code>.getTime()</code> and is the purpose of two date objects and a while loop to avoid the change of returning the same values if called multiple times. Surely the chances of returning the same millisecond representation of the date are slim to none? Any thoughts?</p>