Sorry. Was on vacation (Tahoe, snowboarding/injuring myself). Both answers here are correct, but slightly missing the real issue.
Unlike String, Function, Element, etc, which all have prototypes altered by MooTools, altering Object.prototype is verboten. If you were to add a method to Object.prototype, any object that inherits from it would receive that property (for instance, every Class you write) and, on top of that, if you ever iterated over an object (*for x in y* style) you'd run into those properties. more: http://erik.eae.net/archives/2005/06/06/22.13.54/ On Sat, Jan 23, 2010 at 11:44 PM, אריה גלזר <[email protected]> wrote: > About that specific paragraph - > this is about how JS works. JS is a prototypical language. inheritance is > derived from the prototype of an object (i'm sure this sentence isn't as > correct as it could be but i hope its good enough for this explanation). > Mootools does a lot of it's job by extending the native JS objects - > Function, Element, etc, to make JS better. it does this by extending the > basic prototypes of these objects, thus supplying new methods and behaviors > to their siblings (like Function.bind, Array.each etc). > JS objects literals ({}) are very basic implementation of hashes. The > problem is that unlike other native objects, the object literal prototype > cannot be extended. so instead, Mootools supplies a wrapper class that will > supply you with extended Hash functionality - getters, setters, iterators, > mappers etc > ----------- > אריה גלזר > 052-5348-561 > 5561 > > > On Sat, Jan 23, 2010 at 23:45, waveydab <[email protected]>wrote: > >> Hi, >> >> I'm trying to defog a little on Hash's. My past experience with them >> was in Perl and Python's dictionaries. But this little passage from >> Mootools doc keeps bothering me. I've tried to make sense of it but >> I'm still having trouble. First of all, I didn't know that there was >> an "accounting for prototypes" within a setter or getter. An object >> has properties which may or may not have originated thru a prototype >> but I can't see a requirement for any explicit referencing the >> prototype of such an object for a setter/getter. I'm even less clear >> about what the "iterating" is about. >> >> "A custom Object ({}) implementation which does not account for >> prototypes when setting, getting, or iterating. Useful because in >> JavaScript, we cannot use Object.prototype. Instead, we can use >> Hash.prototype!" >> >> waveydab >> > >
