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

Build Gatsby Websites Using Firestore Data (Without Plugin)

Working with VSAM data sets in Node.js on z/OS

Error Handling in React JS

Node.js Tips — Change Directory with exec, Move Files, and Nested Schemas

Psychology of large JavaScript Project Architecture

How to integrate TestCafe in React app — End to End Testing with TestCafe Beginner guide

React js , Test cafe integration End to End testing

5 Ways to animate a React app in 2019.

Quantity Checks through CSS

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

Polyfills And Helpers — How To Save Your Bundle Size

Front-end and Back-end Explained In Layman’s Terms

A group of people building the front end for a mobile application

AngularJs vs ReactJS: Which is best for your project?

In 2022, learn the 7 best Scala frameworks and libraries for concurrency, web development, and big…