Guest User

Untitled

a guest
Dec 12th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. // Create a naked Object in Old Browsers (eg. IE 6,7,8)
  2. // Object.create(null) or {__proto__: null}
  3.  
  4. function nakedObject() {
  5. var iframe = document.createElement('iframe');
  6. iframe.width = iframe.height = 0;
  7. iframe.style.display = 'none';
  8. document.appendChild(iframe);
  9. iframe.src = 'javascript:';
  10. var proto = iframe.contentWindow.Object.prototype;
  11. iframe.parentNode.removeChild(iframe);
  12. iframe = null;
  13.  
  14. var props = ['constructor', 'hasOwnProperty', 'propertyIsEnumerable', 'isPrototypeOf', 'toLocaleString', 'toString', 'valueOf'];
  15. for (var i = 0; i < props.length; i++) {
  16. delete proto[props[i]];
  17. }
  18. return proto;
  19. }
Add Comment
Please, Sign In to add comment