Skip to content

Instantly share code, notes, and snippets.

@gecbla
Created July 23, 2013 17:20
Show Gist options
  • Save gecbla/6064236 to your computer and use it in GitHub Desktop.
Save gecbla/6064236 to your computer and use it in GitHub Desktop.
Returns a random UUID in javascript
/**
* @see http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript#answer-13403498
* @see https://gist.github.com/jed/982883
*/
function b(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,b)};
var uuid = b();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment