Skip to content

Instantly share code, notes, and snippets.

@serhatates
Created December 13, 2018 10:44
Show Gist options
  • Save serhatates/4dfa1c71b9e4e263270203955cbe97ad to your computer and use it in GitHub Desktop.
Save serhatates/4dfa1c71b9e4e263270203955cbe97ad to your computer and use it in GitHub Desktop.
Generate uuid
function generateUUID() {
var d = new Date().getTime();
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment