Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create a naked Object in Old Browsers (eg. IE 6,7,8)
- // Object.create(null) or {__proto__: null}
- function nakedObject() {
- var iframe = document.createElement('iframe');
- iframe.width = iframe.height = 0;
- iframe.style.display = 'none';
- document.appendChild(iframe);
- iframe.src = 'javascript:';
- var proto = iframe.contentWindow.Object.prototype;
- iframe.parentNode.removeChild(iframe);
- iframe = null;
- var props = ['constructor', 'hasOwnProperty', 'propertyIsEnumerable', 'isPrototypeOf', 'toLocaleString', 'toString', 'valueOf'];
- for (var i = 0; i < props.length; i++) {
- delete proto[props[i]];
- }
- return proto;
- }
Add Comment
Please, Sign In to add comment