Create your own Universally Unique Identifier (UUID)

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

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harry Manchanda

Harry Manchanda

Full Stack JavaScript Developer, Frontend Web Developer | Microservices & DevOPS Enthusiast. | https://www.harrymanchanda.com/