Site Navigation

Saturday, May 10, 2008

bug 253 - more Array issues in IE

Issue: #253
Affects: IE6, IE7, IE8, IE9 PP4

This is more of a minor issue, but its just one more thing you'll need to watch out for.

Example:

<script type="text/javascript">
var foo = ['a','b','c','x','y','z',];
alert(foo.length);
</script>


What would you expect in the alert? 6? Well yes, but not in IE. IE will add a 7th element to the array, which is "undefined".

Think about that for a moment. If the so-called 7th element is "undefined", then why is it there? IE just told us that it is not defined!


Known Workarounds: One. Just be sure that all your Array definitions are "clean" especially if they are generated with some server side code.

Example Workaround Code:

<script type="text/javascript">
var foo = ['a','b','c','x','y','z'];
alert(foo.length);
</script>



Related Issues: (bug 230), (bug 181).

Bug/Site Feedback |
Submit a bug