Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5965529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:38:37+00:00 2026-05-22T19:38:37+00:00

Apparently JS implementation in IE9 contains (IMO, critical) bug in handling array literals. In

  • 0

Apparently JS implementation in IE9 contains (IMO, critical) bug in handling array literals.

In IE9 in some cases this code:

var a = [1,2,3,4,];

will create array of length 5 with last element equals to undefined.

Here are two versions of my KiTE engine test pages:

  • http://terrainformatica.com/kite/test-kite.htm – works in IE9
  • http://terrainformatica.com/kite/test-kite-ie9-bug.htm – fails in IE9

The only difference is that first document contains data.contacts property initialized as [1,2,3,4] and second one as [1,2,3,4,].

Internal IE debugger reports that data.contacts array contains 5 elements in second case. Without debugger this code fails at line 98 in kite.js (trying to get property of undefined – fifth element of that data.content array )

Questions:

  1. How and where people usually report bugs in IE?
  2. Have you seen anything similar to this problem? I am looking for simplest case where this problem is reproducible.

Update: here is the test http://jsfiddle.net/hmAms/ where all browsers (IE9 included) agree on the fact that var a = [1,2,3,4,]; is of length 4.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:38:38+00:00Added an answer on May 22, 2026 at 7:38 pm

    A single trailing comma in an array literal should be ignored. Two trailing commas is an elision and should add one to the array’s length. So:

    alert( [1,2,3,4,].length );   // 4
    
    alert( [1,2,3,4,,].length );  // 5
    

    Some versions of IE (< 9?) treat the single trainling comma as an elison and incorrectly add one to length, so the results above are 5 and 6 respsectively. That is inconsistent with ECMA-262 §11.1.3 and therefore is a bug.

    The purpose of an elision is to increase array length without creating a extra property or assigning directly to length, so:

    var x = [,1,,];
    

    is equivalent to:

    var x = new Array(3);
    x[1] = 1;
    

    The result in both cases should be an array with length 3 and one property named ‘1’ with value 1. The leading comma and trailing comma pair are elisions, they only affect the length, they do not create properties. IE interprets the leading comma correctly but incorrectly interprets both trailing commas as elisions, incrementing the length by 1 too many.

    var x = [,1,,3,,];
    var s = 'length: ' + x.length;
    
    for (var p in x) {
      s += '\nindex ' + p + ' has value ' +  x[p]; 
    }
    alert(s);
    

    The result should be:

    length: 5
    index 1 has value 1
    index 3 has value 3
    

    Incidentally, this bug has probably been around since IE allowed array literals, version 4 at least (1997?).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Paramiko's SFTPClient apparently does not have an exists method. This is my current implementation:
I was slightly confused when, looking through some of the more obscure implementation code
Apparently using the URL is no good - why is this the case, and
Apparently some vendors (like Telerik) are working on versions of their controls that do
I'm writing some code to perform some game theory simulations. My world has several
Since I'm using Java 1.4.2, this means that I cannot use Java's implementation of
This question has to do with PHP's implementation of crypt() . For this question,
I'm doing the Wicked Code implementation of SqlSiteMapProvider, except in VB.NET. There's a few
I trying to convert some loops in my code to use the for_each functionality
Apparently xrange is faster but I have no idea why it's faster (and no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.