1var ID = function () {
2 // Math.random should be unique because of its seeding algorithm.
3 // Convert it to base 36 (numbers + letters), and grab the first 9 characters
4 // after the decimal.
5 return '_' + Math.random().toString(36).substr(2, 9);
6};
1function uuid() {
2 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
3 var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
4 return v.toString(16);
5 });
6}
7
8var userID=uuid();//something like: "ec0c22fa-f909-48da-92cb-db17ecdb91c5"