Skip to content

Instantly share code, notes, and snippets.

@mladen
Created March 19, 2016 14:58
Show Gist options
  • Save mladen/374e35a1fafb9f4b19c8 to your computer and use it in GitHub Desktop.
Save mladen/374e35a1fafb9f4b19c8 to your computer and use it in GitHub Desktop.
// The ID() function will return a unique number every time you call.
// Code is from http://qnimate.com/generate-unique-number-in-javascript/
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