Difference between revisions of "Javascript gid"
From John Freier
(Created page with "This is a function for generating an id. →* * Create a uniqe id. * Example: ae7d31a6-e955-8e2e-ebf5-8863ed74e55d: function guid() { function s4() {...") |
(No difference)
|
Latest revision as of 12:47, 28 May 2015
This is a function for generating an id.
/** * Create a uniqe id. * Example: ae7d31a6-e955-8e2e-ebf5-8863ed74e55d */ function guid() { function s4() { return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); } return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); }