Interview practice question
Generating unique IDs reliably in the browser
Frontend Engineering · JavaScript Core · Experienced
Your app generates IDs with Math.random for offline records, and collisions occur. How would you generate IDs reliably?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Math.random not cryptographically strong; collisions.
- crypto.randomUUID().
- crypto.getRandomValues for custom formats.
- Time-ordered IDs (UUIDv7/ULID) for sorting.
- Server reconciliation.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.