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 };