Create your own Universally Unique Identifier (UUID)

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

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Node.js Tips — Babel, Promises, Latest/Oldest MongoDB Records

JS311 Week 3 — Databases!

BootstrapVue — Checkboxes and Data Lists

Useful JavaScript Tips — Objects, Undefined, and Month Names

LINQ Enhancements in .NET 6

Building a Modern and Compact Frontend Stack.

OWASP Juice Shop — Access ‘Scoreboard’ and ‘Admin section’

Making Pixel Points Medium Widget Accessible

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/

More from Medium

Generate Cryptographic Hashes in your Browser Side Javascript

Setting up node server- Without Express JS

Bankist App: Banking made minimalist.

The Basics of Responsive Web Design