Skip to content

Instantly share code, notes, and snippets.

Created December 28, 2012 07:12
Show Gist options
  • Save anonymous/4395291 to your computer and use it in GitHub Desktop.
Save anonymous/4395291 to your computer and use it in GitHub Desktop.
old IE shim for creating empty dict objects
// pre-ES5 IE version
var dict = (function() {
var PROPERTY_KEYS = [
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable"
"valueOf",
"toString",
"toLocaleString",
"constructor"
];
var frame = document.createElement("iframe");
document.body.appendChild(frame);
var proto = frame.contentWindow.Object.prototype;
document.body.removeChild(frame);
for (var i = 0, n = PROPERTY_KEYS.length; i < n; i++) {
delete proto[PROPERTY_KEYS[i]];
}
function Dict() { }
Dict.prototype = proto;
function dict() {
return new Dict();
}
return dict;
})();
@ziyunfei
Copy link

"propertyIsEnumerable",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment