Created
August 11, 2014 15:09
-
-
Save madfriend/30ad5e57eecf6161fad0 to your computer and use it in GitHub Desktop.
Object.uniqueId from http://stackoverflow.com/a/7579956
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() { | |
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