Let's say you want to add a method to all the elements in your HTML document. Normally, to do this, you will use Element.prototype
as below:
Element.prototype.foo = function() {
return "foo";
};
Let's say now you want to include a library called bar.js in your document. But unbeknownst to to you, there is a piece of code in bar.js that overwrites the foo()
method of Element.prototype
as below: