Skip to content

Instantly share code, notes, and snippets.

@sandcastle
Created November 5, 2015 12:40
Show Gist options
  • Select an option

  • Save sandcastle/16783a3fe74496b2d8ae to your computer and use it in GitHub Desktop.

Select an option

Save sandcastle/16783a3fe74496b2d8ae to your computer and use it in GitHub Desktop.
Generates a new UUID in js.
function getUuid() {
function _p8(s) {
var p = (Math.random().toString(16) + "000000000").substr(2, 8);
return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p;
}
return _p8() + _p8(true) + _p8(true) + _p8();
};
@sandcastle

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment