On Mar 30, 11:23 am, "[email protected]" <[email protected]> wrote: > On Mar 30, 11:05 am, Joey <[email protected]> wrote: > > > My map works fine in Firefox, but within IE6 version 6.0.29 I get the > > following error: > > ... > > Error: Object expected > > The error above is due to this: > "Washington": [],}; > > (you have an extra "," at the end of the object which causes IE to > append a null entry.
It's worth mentioning that this behavior -- I call it the "null last item problem" -- is behind many of IE's seemingly obtuse Javascript errors. Having been spoiled working in other programming languages, I've been bitten by this several times. I have stared and debugged and re-coded and repeated until feelings of doom and impulses of violence start upsetting my normal balance. Now I work to avoid the final comma in the first place. This applies to arrays, lists, function & method arguments, etc. A common occurrence of the the final comma is in JSON, object literals, and other strings generated by code, where each appended item has a trailing comma to simplify list concatenation with the next item. The other source of the problem (for me) is copying & pasting arguments or list items, inadvertently leaving a trailing comma. Just remember that in JS the comma is an OPERATOR; as in many other languages, it evaluates the item on its left, then the item on its right, and returns the item on the right. In IE's implementation, having nothing on the right of the comma means that it will return nothing, i.e., null. Other implementations of JS seem to decide that "nothing" to the right of the last comma means that the list has terminated before the last comma, so no final item is returned. [Note that I haven't researched the specs of various JS implementations, so this statement might be too broad.] It can be argued that IE's is actually the correct, or consistent, behavior. I won't take more space here to suggest ways to programmatically deal with trailing commas, as that's purely a Javascript issue. So when IE gives you a Map error, and throws you deep into some of the Google Maps API's obfuscated code libraries, it's probably not an API bug; very likely somewhere in your code there's a little comma just doing its job. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" 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-API?hl=en -~----------~----~----~----~------~----~------~--~---
