![]() |
Ever heard of GUID (Globally Unique Identifier) or UUID (Universally Unique Identifier)? These are 128-bit unique identifiers used in computer systems to distinguish resources like files, objects, and components. Generated randomly, GUIDs are extremely unlikely to be duplicated. They find applications in databases, web apps, and operating systems. Typically, GUIDs are represented as strings of 32 hexadecimal digits, for instance, “550e8400-e29b-11d4-a716-446655440000”. The generation process involves a mix of timestamps, random numbers, and network address data. Syntax: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx Parameters:
Approach
Example 1: In this example, a concise JavaScript function generates a random UUID following the ‘xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx’ pattern. The UUID includes randomly generated hexadecimal digits, a fixed ‘4’ for version indication, and a digit following a specific pattern denoted by ‘y’. The function then prints the generated UUID to the console using
Output 8e8679e3-02b1-410b-9399-2c1e5606a971 Example 2: In this example, a succinct JavaScript code snippet utilizes the ‘uuid’ library to generate a random UUID. The
Output: 93243b0e-6fbf-4a68-a6c1-6da4b4e3c3e4 |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |