Created
October 21, 2017 22:55
-
-
Save banhaclong20/04667adc1070d09f10c3595fb9beca15 to your computer and use it in GitHub Desktop.
Generate Unique Number in JavaScript
This file contains 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 uniqueNumber() { | |
var date = Date.now(); | |
if (date <= uniqueNumber.previous) { | |
date = ++uniqueNumber.previous; | |
} else { | |
uniqueNumber.previous = date; | |
} | |
return date; | |
} | |
uniqueNumber.previous = 0; | |
function ID(){ | |
return uniqueNumber(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment