Skip to content

Instantly share code, notes, and snippets.

@satbirdd
Created September 24, 2014 13:57
Show Gist options
  • Save satbirdd/0e1f34e9fb43f92d2534 to your computer and use it in GitHub Desktop.
Save satbirdd/0e1f34e9fb43f92d2534 to your computer and use it in GitHub Desktop.
generate id for javascript class
function A () {
this.generateId();
}
A.prototype.generateId = (function () {
var count = 0;
return function () {
count ++;
this.id = count;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment