Function generateUUID

  • Generates v4 like UUID (Universally unique identifier).

    Be aware that UUID uniqueness relies heavily on the underlying random number generator (RNG). The solution above uses Math.random() for brevity, however Math.random() is not guaranteed to be a high-quality RNG. For a more robust solution, consider using the uuid module, which uses higher quality RNG APIs.

    Returns string

    Example

    generateUUID()
    // '8e07ef4a-0d1f-45c2-b06b-9495e869b299'