On Nov 21, 6:35 pm, "stijn.m" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I had a problem with prototypejs when it came to for ... in loops for
> associative arrays.

Javascript does not have associative arrays, it has objects.


> Usually this gets solved by changing the array
> into object (or changing the loop for regular arrays), but in some
> cases I had to leave the possibility for a function to accept
> associative arrays anyhow. This is how I solved it.

Use the built-in Object.prototype.hasOwnProperty method.  You could
also use propertyIsEnumerable, but I can't think why it is better than
hasOwnProperty.

[...]

> function isValue(val) {
>     if(navIsSafari || navIsKonqueror) {

If you ever find the need to resort to browser sniffing, you can be
almost certain there is a better way.


--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to