Typescript Create Unique ID
- #TypeScript
- #Date
Typescript Create Unique ID
Math.round should be unique because of its seeding algorithm and also should be different because we are basing it off of Date.now() while converting this to a base 36 (numbers + letters)
const randomUniqueString = Math.floor(Math.random() * Date.now()).toString(36);
const id = `test-id-${randomUniqueString}`;
0 Comments
Sign in to join the conversation.