Sunday, 15 March 2015

Prototyping Object in Javascript breaks jQuery? -


I have added a simple .js file to my page in which some very common worldly The task is added in the object and array prototype.

Through trial and error, I have thought that Object.prototype does not matter, or it causes javascript errors in jQuery:

The culprit?

  Object.prototype.foo = function () {/ * nothing and break jQuery};  

I am getting the line 1056 of jquery-1.3.2.js , in the entry: function {} declaration:

  / * Object does not support this property or method * / name = name.replace (/ - ([az]) / ig, function (all, characters) {return letter.toUpperCase ();});  

Apparently live. Blank is undefined.

Although it is clear that there is something that I am not wrapping my head with prototype, I have failed to understand what it is.

To be clear, I am not looking for an alternative solution, I have handled it ... What I see is Why? . Why does the object.prototype add functions to break this code code?

You should never expand Object.prototype Is more than; Do not do this, it completely breaks the Javascript's "object-to-hashtables" feature.

You can ask John Raisig, and he'll tell you.


No comments:

Post a Comment