Ok, thank you again, TJ

On Dec 11, 1:50 pm, "T.J. Crowder" <[email protected]> wrote:
> Hi,
>
> `Object` is deep in the core of JavaScript, not just Prototype.
>
> You can add static functions to `Object` fairly safely provided you
> use obscure names:
>
>     Object.myReallyObscureMethodName = function() {
>         // ....
>     };
>
> ...but as you mentioned, you will be susceptible to naming conflicts.
>
> What you must **never** do is add to `Object.prototype`:
>
>     // DON'T DO THIS
>     Object.prototype.myReallyObscureMethodName = function() {
>         // ....
>     };
>
> If you do that (the way it's shown above), then just about every
> `for..in` loop in code running alongside yours will fail, because the
> above adds an enumerable `myReallyObscureMethodName` property to *all
> objects*:
>
>     var name;
>     for (name in {}) {
>         alert(name); // This gets reached, and alerts
> "myReallyObscureMethodName"
>     }
>
> ...and that's just a Bad Thing(tm). (As of ECMAScript 5th edition,
> it's *possible* to add non-enumerable properties to `Object.prototype`
> using special syntax, but I still wouldn't do it.)
>
> HTH,
> --
> T.J. Crowder
> Independent Software Engineer
> tj / crowder software / com
> www / crowder software / com
>
> On Dec 11, 12:07 am, Luke <[email protected]> wrote:
>
>
>
> > Hi,
>
> > is it ok to extend Object (http://api.prototypejs.org/language/Object/
> > ) with a custom function (I mean regarding name-conflicts, I want to
> > name my function extendWrapped)? Or is it a Class that should better
> > not be touched for some reason? It seems to be pretty deep in the core
> > of Prototype, so I'm kinda cautious..
>
> > Thanks
> > Lukas

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to