Juan R Labrada

Note Details
OVERLINE
How to generate unique random ids

Having unique ids is a frequent need. Sometimes using a database can help on this but at the cost of speed. Here are a few faster alternatives.

Unodered
"".concat(Math.round(1e12*Math.random())).concat(Date.now())

Ordered
"".concat(Date.now()).concat(Math.round(1e12*Math.random()))

Rate this note
Comment
Comments
Back to Notes