javascript create random unique string code example
Example 1: javascript generate random string
// Generate a random alphanumerical string of length 11 ( change substring parameter for other length)
Math.random().toString(36).substring(2);
Example 2: javascript generate unique id
function randomId(): string {
const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0];
return uint32.toString(16);
}