rasensio
4/24/2015 - 3:00 PM

Get a UUID in Javascript

Get a UUID in Javascript

function uuid() {
  
  function d4() {
    return Math.floor((1 + Math.random()) * 0x10000)
      .toString(16)
      .substring(1);
  }
  
  return d4() + d4() + '-' + d4() + '-' + d4() + '-' +
    d4() + '-' + d4() + d4() + d4();
}