Field Notes from the Workshop · № 201 Javascript

GUID generator in JavaScript

Joshua Doodnauth Software Engineer · Toronto
December 2, 2008 1 min read 104 words

Found two little functions in JavaScript to create a GUID
[javascript]function S4(){
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}

function guid() {
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}[/javascript]
Thanks to sj at note19.com, I don’t know exactly how reliable the generator is, I ran a couple tests against 50 guids, and it passed, but I need to run the guids through the Windows Installer using WiX, and I don’t know if there will be conflicts

I am still open to any other JavaScript generators if anyone knows of any