You might be interested in my "CodeWhile" episode 012, on YouTube:
It discusses the following code:
[...]
(function() {
var cleanBroken;
var cleanNewId;
var newGetId;
if (typeof Object.prototype["&_"] != "undefined")
return;
cleanBroken = (new Function("return broken;\n" + broken.toString()))();
newGetId = new Function("id", "newId", "value", "return getId;\n" + getId.toString());
cleanNewId = (new Function("broken", "id", "newGetId", "return newId;\n" + newId.toString()))(cleanBroken, 1, newGetId);
cleanNewId(Object.prototype);
return;
function broken() { throw new Error("\"&_\" seems to be broken for this value"); }
function getId()
{
if (arguments.length != 0)
throw new Error("Takes no arguments");
if (this["&_"] !== getId && typeof this["&_"] == "function")
return this["&_"].call(this);
if (this === value)
return id;
return newId(this);
}
function newId(value)
{
value["&_"] = broken;
if (id == 0x20000000000000)
throw new Error("Too many IDs");
id += 1;
value["&_"] = newGetId(id, newId, value);
return id;
}
})();
[...]
The general idea is that some_object["&_"]() will give a unique, numeric ID for each object and/or function. Even if the property is copied from one object/function to another, calling the utility on the destination will not yield the same ID as the source of that copy.
This code should work pretty broadly, including Microsoft Internet Explorer 6. (In that web-browser, HTML elements do not inherit from Object.prototype, but this utility can still be .call()ed on those elements.) That is, "as far back as" ECMAScript 3, if I recall correctly.
It's possible that some comments to this "answer" might result in responses that refer to the aforementioned video.