One Possible Cause for "[Object] is Undefined” in IE

This one took me way too long to figure out. (And yes, it’s a stupid mistake that led to way too much debugging). Firefox allows this as a valid object:

{  foo: 'bar', baz: 75, }

Note the extra comma that shouldn’t be there as there’s no successive name/value pair. IE throws a fit at this, and declares the object invalid. (I tried to see if this is valid or invalid code in a JavaScript spec, but my quick research didn’t yield any results. It seems wrong from a coding-standards point of view.)

Note also that if this type of code appears anywhere in an object you’ve created, like as a property or method IE will declare the entire Object invalid.

technorati tags:,

Comments are closed.

I'm Reading…
Search This Site

AddThis Feed Button

Need great hosting?

Categories