GUID generator (nonfiction): Difference between revisions
Jump to navigation
Jump to search
(Created page with "GUID generator (JavaScript): <code> var Guid = (function () { function Guid(guid) { this.guid = guid; this._guid = guid; } Guid.prototype.ToString...") |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 26: | Line 26: | ||
return Guid; | return Guid; | ||
}()); | }()); | ||
Guid.MakeNew().ToString(); | Guid.MakeNew().ToString(); | ||
</code> | </code> |
Latest revision as of 08:27, 17 May 2019
GUID generator (JavaScript):
var Guid = (function () {
function Guid(guid) {
this.guid = guid;
this._guid = guid;
}
Guid.prototype.ToString = function () {
return this.guid;
};
// Static member
Guid.MakeNew = function () {
var result;
var i;
var j;
result = "";
for (j = 0; j < 12; j++) {
if (j == 8 || j == 12 || j == 16 || j == 20)
result;
i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
result = result + i;
}
return new Guid(result);
};
return Guid;
}());
Guid.MakeNew().ToString();