Created
October 3, 2013 19:07
-
-
Save brianmriley/6815266 to your computer and use it in GitHub Desktop.
JavaScript Simple GUID Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// internal function to generate a random number guid generation | |
var S4 = function() { | |
return (((1+Math.random())*0x10000)|0).toString(16).substring(1); | |
}; | |
// generates a guid for adding items to array | |
var createGUID = function () { | |
return (S4() + S4() + "-" + S4() + "-4" + S4().substr(0,3) + "-" + S4() + "-" + S4() + S4() + S4()).toLowerCase(); | |
}; | |
var guid = createGUID(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment