1.

What is UUID, and how you can generate it in Node.js?

Answer»

A UUID is a Universal Unique Identifier is a method for generating ids that have been standardized by the Open Software Foundation (OSF).

You can generate UUIDs in Node.js through the node-UUID. It is a speedy and straightforward way of generating VERSION 1 & 4 UUIDs.

Here's how to generate UUIDs
  • Install the node-uuid through the npm manager using npm install uuid.
  • Use it in your script like this:

CONST uuidv1 = require('uuid/v1')
const uuidv4 = require('uuid/v4')
var uuid1 = uuidv1()
var uuid5 = uuidv4()

Here is how your OUTPUT would look. ALTHOUGH, due to the nature of UUIDs, your GENERATED IDs may be completely different.

Output

uuid1 v1 => 6bf958f0-95ed-17e8-sds37-23f5ae311cf6
uuid5 v4 => 356fasda-dad8d-42b7-98b8-a89ab58a645e

 



Discussion

No Comment Found