Create a gist now

Instantly share code, notes, and snippets.

anonymous /dict-ie.js
Created Dec 28, 2012

What would you like to do?
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;
})();

"propertyIsEnumerable",

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