JS 生成GUID 方法

var Guid={NewGuid: function () {
var guid = (this._G() + this._G() +"-"+ this._G() +"-"+ this._G() +"-"+ this._G() +"-"+ this._G() + this._G() + this._G()).toUpperCase();
return guid;
},
_G: function () {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}
};
console.log(Guid.NewGuid());
console.log(Guid.NewGuid());
console.log(Guid.NewGuid());
console.log(Guid.NewGuid());
// rfc4122 version 4
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
上一篇:解读直播间搭建的直播带货系统,直播间搭建的要点


下一篇:oracle Clob类型转换成String类型