Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@madfriend
Created August 11, 2014 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madfriend/30ad5e57eecf6161fad0 to your computer and use it in GitHub Desktop.
Save madfriend/30ad5e57eecf6161fad0 to your computer and use it in GitHub Desktop.
Object.uniqueId from http://stackoverflow.com/a/7579956
(function() {
var id_counter = 1;
Object.defineProperty(Object.prototype, "__uniqueId", {
writable: true
});
Object.defineProperty(Object.prototype, "uniqueId", {
get: function() {
if (this.__uniqueId == undefined)
this.__uniqueId = id_counter++;
return this.__uniqueId;
}
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment