Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
53 views

Guid in Javascript: Try It Out Now! Bytes Here

This document provides code to generate strings that resemble Globally Unique Identifiers (GUIDs) in JavaScript. The code uses random numbers to generate string segments and combines them with dashes. However, these strings are not guaranteed to be truly unique. The document warns that this code should not be used if unique identifiers are critically important and provides a link to find a standard-compliant GUID generator.

Uploaded by

Kosta Nikolic
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Guid in Javascript: Try It Out Now! Bytes Here

This document provides code to generate strings that resemble Globally Unique Identifiers (GUIDs) in JavaScript. The code uses random numbers to generate string segments and combines them with dashes. However, these strings are not guaranteed to be truly unique. The document warns that this code should not be used if unique identifiers are critically important and provides a link to find a standard-compliant GUID generator.

Uploaded by

Kosta Nikolic
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

GUID in JavaScript

Its easy to make GUIDs in JavaScript. Below is code to get strings that look like GUIDs. This
code just random GUIDs they are not claimed to be unique. Don't use these if its very
important.
1function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
2
}
3
4// then to call it, plus stitch in '4' in the third group
5guid = (S4() + S4() + "-" + S4() + "-4" + S4().substr(0,3) + "-" + S4() +
6"-" + S4() + S4() + S4()).toLowerCase();
7alert(guid);
Try it out now!
code thanks to: BYTES These guys are so GUID they UUed my ID.
A heavy duty version that meets the GUID standards can be found here.

You might also like