Create your own Universally Unique Identifier (UUID)
Jan 9, 2021
You can create your own UUID with this below JavaScript function:
function uuidv4() { const init = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"; return init.replace(/[xy]/g, (c) => { const r = Math.random() * 16 | 0; const v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); });}
Then, You would need to execute this function to generate a random UUID string. Every Time you execute there will be a new string.
uuidv4(); // => 2fb0c438-a38b-4be0-9d53-df309a2ded95uuidv4(); // => 6f48aa1a-fd44-454b-b796-bca06070d624