Wednesday, April 12, 2023

Create a unique ID with javascript time

Create a unique number with javascript time - Stack Overflow

Date.now().toString(36)

'lge1j7wp'

How to generate a Unique ID in JavaScript - Clue Mediator


1
2
3
4
5
6
const uid = function(){
  return Date.now().toString(36) + Math.random().toString(36).substr(2);
}
 
console.log(uid());
// Output: kyg0z26npc43wq7vaa

No comments: