GUID生成器

1 Math.guid = function() {
2     return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
3         var r = Math.random() * 16 | 0,
4             v = c == 'x' ? r : (r & 0x3 | 0x8);
5         return v.toString(16);
6     }).toUpperCase();
7 };
posted @ 2012-08-05 14:24  小猩猩君  阅读(831)  评论(0编辑  收藏  举报