Re: Fallback property getter in JavaScript?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Fallback property getter in JavaScript?

Brendan Eich
[hidden email] wrote:
> hostObject["favoriteColor"].matches("blue", "red", "yellow");
> //returns true when the host object represents data set with a
> favoriteColor value of any in the list
> hostObject["favoritePet"].matches("dog", "cat");
> //always returns false, because the hostObject represents data set with
> no favoritePet defined.

First, hostObject.favoritePet is equivalent, and shorter by two chars if
the right-hand side is a lexical identifier.  Not sure why you were
using [""] here.

Second, if the value is a string, why not use regular expression?


and avoid any extensions for this part.

Finally, to resolve favoritePet or favoriteColor where neither is
predefined, you'll need some kind of extension.  shaver has a patch in
bug 312116 ( that
will help you implement what you want in JS, so try that patch and give
him testing feedback.

mozilla-jseng mailing list
[hidden email]