I was trying to delete .insertBefore(); of HTMLElement.prototype but when I check for it, instead of an undefined value, it returns the actual function? Why?
console.log(HTMLElement.prototype.insertBefore); // function insertBefore() { [native code] }
delete HTMLElement.prototype.insertBefore;
console.log(HTMLElement.prototype.insertBefore); // function insertBefore() { [native code] }
Can you explain why this isn’t working. I tried this on my own constructor and it worked, but for the built in ones, it didn’t.
You cannot use DELETE like that:
http://perfectionkills.com/understanding-delete/
Seriously man, read that article. It has a ludicrously clear and concise explanation of all this!
Note: even though they have the
dontDeleteattribute set, you can still overwrite it: