JavaScript Object Id [duplicate]
This question already has an answer here: unique object identifier in javascript 11 answers Do JavaScript objects/variables have some sort of unique identifier? Like Ruby has object_id . I don't mean the DOM id attribute, but rather some sort of memory address of some kind. No, objects don't have a built in identifier, though you can add one by modifying the object prototype. Here's an example of how you might do that: (function() { var id = 0; function generateId() { return id++; }; Object.prototype.id = function() { var newId = generateId(); this.id = function() { return newId; }; return