DEV Community

Discussion on: How to Generate Unique ID in JavaScript

Collapse
 
peledzohar profile image
Zohar Peled

In fact, random numbers probability of uniqueness is actually a lot smaller than what one can expect, without knowledge of what's called the birthday problem.

In a nutshell - Take a group of random people. What are the chances two of them was born in the same date (day and month, year not included)?

Turns out, that if the group contains 32 people, that chance is 50%. With 70 people in the group, its 99.9%.

So the chances of getting the same random number twice when your range is between 0 and 100 increase rapidly the larger the group is.