After modified Object.prototype
, all of jQuery's methods running on selectors started resulting in the below error:
Uncaught TypeError: matchExpr[type].exec is not a function
And also when I call $.post()
. it says that
$.post() is not undefined
What I did was:
Object.prototype.extend = function(object) {
...
}
What am I missing here?
Rule #1: Avoid Monkey Patching at all costs!
Overriding methods of built-in Objects (via the prototype property, as in your example) is a major anti-pattern and it's considered a really, really bad practice!
You just need to think of another way to accomplish what you are trying to achieve, without overriding these methods.
You might want to take a look at jQuery's extend method for example.