Created
March 11, 2019 23:44
-
-
Save matthlavacka/cf710121a286e92d9cec2d6a85994c80 to your computer and use it in GitHub Desktop.
Random ID in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uniqueId() { | |
// Math.random should be unique because of its seeding algorithm. | |
// Convert it to base 36 (numbers + letters), and grab the first 9 characters | |
// after the decimal. | |
return Math.random() | |
.toString(36) | |
.substr(2, 9); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment