Skip to content

Instantly share code, notes, and snippets.

@Xsmael
Last active February 12, 2019 21:58
Show Gist options
  • Save Xsmael/9b9c74e0a6063b4b1db42eb1194450fe to your computer and use it in GitHub Desktop.
Save Xsmael/9b9c74e0a6063b4b1db42eb1194450fe to your computer and use it in GitHub Desktop.
Simple guaranteed unique, fast enough, not too long, id generator in JavaScript
//Guaranted unique fast enough id generator in JavaScript
function getUID() {
return Math.random().toString(36).substring(2, 15)
+'-'+Math.random().toString(36).substring(2, 15)
+'-'+Date.now().toString(36);
}
// inspired from https://stackoverflow.com/a/13403498/2429678
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment