Creating a globally unique identifier has always been a necessity in all programming languages and for some reason, JavaScript never had a way of doing it in the default spec. But that is changing now with the crypto API. We can now create a UUID in JavaScript.
A universally unique identifier (UUID) is a 128-bit label used for information in computer systems. The term globally unique identifier (GUID) is also used instead of UUID.
For example: “4ab4e2a1-0efb-4e5b-8f73-e503f5b8e89f”
Traditionally, we needed to use either Math.Random(), or the Date object and then convert it into a UUID format. But now all we need is:
crypto.randomUUID() // "819df8d4-587b-4200-90b3-d30f8ed01457"
JavaScriptIt is important to note that it still might not generate a unique value though the probability of that happening is fairly low.
I am terrible at optimizing my keyboard layout for anything. But off lately, my little…
I recently switched completely to the Brave browser and have set ad blocking to aggressive…
I was preparing a slide deck for a hackathon and decided to put in a…
I have been using npx a lot lately, especially whenever I want to use a…
Manually copy-pasting the output of a terminal command with a mouse/trackpad feels tedious. It is…
While working on a project, I wanted to do an integrity check of a file…