There is no such helper function in JS. You can generate a fairly random hash using:
function hex(n){
n = n || 16;
var result = '';
while (n--){
result += Math.floor(Math.random()*16).toString(16).toUpperCase();
}
return result;
}
You can modify it to form a guid:
function generateGuid(){
var result = '', n=0;
while (n<32){
result += (~[8,12,16,20].indexOf(n++) ? '-': '') +
Math.floor(Math.random()*16).toString(16).toUpperCase();
}
return result;
}
source
share