Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No. IE incorrectly interprets a single trailing comma as an elision and adds one to the length when it shouldn't (ECMA-262 sect. 11.1.4). </p> <h3>Edit</h3> <p>To clear up the confusion here, IE treats a single trailing comma in an array literal (incorrectly) as an elision, which means it increments array's length property <strong>but does not create a property</strong>. In other words, given:</p> <pre><code>var a = [0,1,]; </code></pre> <p>In IE, a.length is 3, but there is no property a[2]. So if an appropriate solution is to remove only <strong>elided</strong> members from the end of an array (which is likely the best solution if they are an issue), then:</p> <pre><code>function tidyTrailingElisions(array) { var i = array.length; while (!array.hasOwnProperty(--i)) {} array.length = ++i; return array; } </code></pre> <p>will remove <strong>only</strong> elided members from the end of the array (that is, properties that don't exist), it will not remove them elsewhere, nor will it waste time iterating over the entire array (which can result in elided members being added as undefined). To add to Array.prototype:</p> <pre><code>Array.prototype.tidyTrailingElisions = function() { var i = this.length; while ( !this.hasOwnProperty(--i)) {} this.length = ++i; return this; }; </code></pre> <p>Note that this is how <em>Array.prorotype.filter</em> works, it doesn't iterate over elided members (it uses a <em>hasOwnProperty</em> test and removes any elided mebers as part of filtering the array).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload