Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Created July 24, 2015 10:09
Show Gist options
  • Save JavaScript-Packer/e255077912a674a19d83 to your computer and use it in GitHub Desktop.
Save JavaScript-Packer/e255077912a674a19d83 to your computer and use it in GitHub Desktop.
Function to get a unique guid of the specified length (32 is default)
function guid(t) {
var a, r = [], e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = e.length;
for (t = t || 32, a = 0; t > a; a++) {
r[a] = e.charAt(Math.floor(Math.random() * n));
}
return r.join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment