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.
Do JavaScript objects/variables have some sort of unique identifier? Like Ruby has object_id .
Share
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:
That said, in general modifying the object prototype is considered very bad practice. I would instead recommend that you manually assign an id to objects as needed or use a
touchfunction as others have suggested.