title: Collisions when generating UUIDs in JavaScript
body: <p>This relates to <a href="https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript">this question</a>. I am using the code below from <a href="https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523">this answer</a> to generate a UUID in JavaScript:</p>
  <pre><code>'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
      var r = Math.random()*16|0, v = c == 'x' ? r : (r&amp;0x3|0x8);
      return v.toString(16);
  });
  </code></pre>
  <p>This solution appeared to be working fine, but I am getting collisions. Here's what I have:</p>
  <ul>
  <li>A web application running in Google Chrome.</li>
  <li>16 users.</li>
  <li>about 4000 UUIDs have been generated in the past two months by these users.</li>
  <li>I got about 20 collisions - e.g., a new UUID generated today was the same as about two months ago (different user).</li>
  </ul>
  <p>What is causing this issue and how can I avoid it?</p>