Instead of testing to see if an object property is a function you could use the hasOwnProperty() method:
http://www.google.co.uk/search?x=0&y=0&q=javascript+hasownproperty&ie=UTF-8&oe=UTF-8 Martin. On Feb 24, 6:04 pm, Yves <[email protected]> wrote: > On 24 Feb., 18:32, Michael Geary <[email protected]> wrote: > > > I also wish the language made > > it a reasonable proposition to add Object.prototype methods - and as Ben > > mentioned future versions will - but at the moment it's not very practical > > because of the for..in loop problem. > > It would already help a lot if you just skipped all function-type > things in those loops, as you probably don't want to iterate them. > > I'm currently looking at my JS library and have begun rewriting it > from extending all sorts of class prototypes to use separate classes, > but it just - looks - so ugly! And it's way less readable. So while > Google is having some fun writing their code, my pain increases just > about the same writing and using my code. That's not fair (from my > POV). > > Take > > for (var prop in obj) { ... } > > and replace it with > > for (var prop in obj) if (typeof obj[prop] !== "function") { ... } > > Make a template in your editor if you don't want to type if every > time. > > Here's my code: (just one example out of many) > > String.prototype.trim = function (c) { return > this.trimStart(c).trimEnd(c); }; > > vs. > > this.trim = function(s, c) { return self.trimEnd(self.trimStart(s, c), > c); }; > > The second one is hard to follow. -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" 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/google-maps-js-api-v3?hl=en.
