"Adding checks into the library would add overhead"
Did you make some performance tests ?

If it's so BAD why Douglas Crockford in his book[1] has no problem
with object.prototype augmentation ?

For example, take a look : http://javascript.crockford.com/prototypal.html
He says : "The problem with Object.prototype.begetObject is that it
trips up incompetent programs[..]"


[1] http://oreilly.com/catalog/9780596517748/

/Greg

On Jul 22, 2:37 pm, Gordon <[EMAIL PROTECTED]> wrote:
> Playing around with the prototypes of built in objects is considered a
> REALLY BAD THING for exactly the reasons you've encountered.  Most
> javascript, not just jQuery, makes assumptions about the built in
> Javascript objects, assumptions that get invalidated when the object's
> prototype has been mucked around with.  Adding checks into the library
> would add overhead, something that could have enormous impact on
> complex web apps.
>
> On Jul 22, 11:36 am, Greg <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
> > I want to use the code from this page 
> > :http://www.coolpage.com/developer/javascript/Correct%20OOP%20for%20Ja...
> > to enable true inheritance with JavaScript ... but sadly JQuery
> > doesn't support a such possibility.. Why ?
>
> > If you take care by using "hasOwnProperty()" when you iterate to an
> > object you will never reach my added functions. Like that :
> > for(var m in o) {
> >    if (m.hasOwnProperty()) {
> >       // use of m..
> >    }
>
> > }
>
> > Or better with a such augmentation ;o) :
> > Object.prototype.each = function(f) {
> >    for (var k in this) {
> >       if (this.hasOwnProperty(k)) {
> >          f(k, this[k]);
> >       }
> >    }
>
> > };
>
> > Is there an explanation of this limitation ?
>
> > TIA
> > /Greg

Reply via email to