Object.prototype.doSomething = function(p) {
this.innerHTML = "<em>bar</em>";
this.style.color = "#f00";
alert(p);
};
document.getElementById("foo").doSomething("Hello World");
<div id="foo"><strong>foo</strong></div>
The code above works fine.
But I remember that I saw this somewhere: Do not mess with native Object.
well, something like that.
So is it ok to define a prototype function on Object? Are there any reasons that I should not do this?