Well I cannot reproduce it in IE8 compatability mode in IE10 but
defining a property like "toLocaleString"
should work because of the don't enum bug in IE8.
var uniqueId = function() {
var dontEnumBug = false;
var id = 0;
if( !Object.defineProperty ) {
var keyVisited = false;
for( var k in {toLocaleString: 3}) {
if( k === "toLocaleString" ) {
keyVisited = true;
}
}
if( !keyVisited ) {
dontEnumBug = true;
}
}
return function( obj ) {
if( dontEnumBug ) {
obj.toLocaleString = id++;
}
else {
Object.defineProperty(obj, '__id__', { enumerable: false, value: id++ });
}
}
})();
You could also use "isPrototypeOf"
or "propertyIsEnumerable"
as these are also functions that are pretty much never called.