Tuesday, August 21, 2012

IE Shenanigan Part 1: Javascript Array

NO trailing comma/s on your javascript arrays.

<script type='text/javascript'>

    var myArray = {
        "a":"apple",
        "b":"banana",
        "c":"carrot", // this, here, is a trailing comma
    }

</script>

If you encounter a javascript error in your page when using Internet Explorer, you might want to check your javascript arrays for trailing commas.  While other browsers don't mind, apparently IE doesn't want those kinds of things, so better remove them and try loading your page again.


No comments:

Post a Comment