当前位置:网站首页>js 实现随机生成UUID
js 实现随机生成UUID
2022-07-23 07:49:00 【凯小默】
function uuid() {
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
var uuid = s.join("");
uuid = uuid.split("-").join("");
return uuid;
}
边栏推荐
猜你喜欢

解决报错:Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “

达人评测 酷睿i9 12950hx和i9 12900hx区别哪个强

Establish stm32f103c8t6 project template and STM32 st-link utility burn hex file

背包问题详解

In depth analysis of common cross end technology stacks of app

Day108.尚医通:医院模拟系统接口对接 - 医院|科室|排班 增删改分页条件查询

京东云分布式链路追踪在金融场景的最佳实践

Ansible first knowledge of learning one

Creo 9.0 中几何对象的选取方法

锐龙R7 PRO 5875U性能怎么样?相当于什么水平级别
随机推荐
图像处理3:Sobel边缘检测
Head products generated 2.5 billion yuan, and SLG track was also targeted by black products
LeetCode_ 47_ Full arrangement II
判断一个对象是否是空对象的处理办法
pingbanceshi
rtx3070ti显卡什么水平 rtx3070ti显卡什么级别 rtx3070ti显卡怎么样
Golang remote server debugging
配置firecracker流程即踩坑记录
Matlab: convert PNG pictures into txt files
《乔布斯传》英文原著重点词汇笔记(十五)【 chapter fourteen】
kafka消费报错coordinator unavailable.Rediscovery will be attempt redisCovery
rtx3080ti和3090差距 rtx3080ti和3090哪个性价比高
These five points should be considered in the production of enterprise science and technology exhibition hall
图像处理1:RGB888_YCbCr444
RIP实验
腾讯MMKV的原理与实现
KingbaseES 格式化函数
Remember that a vulnhub target plane exercise successfully won the root permission
C#:in、out、ref關鍵字
Excel essay record