This question already has an answer here:
Create GUID / UUID in JavaScript? 49 answers
You have differents choices:
Take the compacted version by Broofa Take this version which add uuid method to Math object. Then just call Math.uuid() to generate a random UUID, also by Broofa. A complete library for multiple operation on the uuid, for exemple you could use the version 4 (random-numbers-based) as well as the version 1(time-based). To finish, as said in the comment there are 340,282,366,920,938,463,463,374,607,431,768,211,456 possible UUIDs, so don't worry about generating twice the same, you would have more chance trying to win lottery 1 billion times.
链接地址:
http://www.djcxy.com/p/16246.html
上一篇:
如何在javascript中获得纯粹唯一的数字
下一篇:
我如何生成一个uniqueidentifier