Skip to content

Instantly share code, notes, and snippets.

@kidker
Created January 1, 2018 00:09
Show Gist options
  • Save kidker/38fd9d709c0238926373c26975bab89a to your computer and use it in GitHub Desktop.
Save kidker/38fd9d709c0238926373c26975bab89a to your computer and use it in GitHub Desktop.
JS GUID V4
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment