Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A nice thing about Javascript is that its semantics is formally and as unambiguously as possible defined in the standard. Specifically, <a href="http://es5.github.io/#x15.4" rel="nofollow">section 15.4</a> states that:</p> <blockquote> <p>The value of the length property is numerically greater than the name of every property whose name is an array index; whenever a property of an Array object is created or changed, other properties are adjusted as necessary to maintain this invariant. </p> </blockquote> <p>In other words, everytime you change an array, its <code>length</code> is adjusted, however, it's only guaranteed to be greater than <code>max(indexes)</code>, and not necessarily equal to <code>max(indexes)+1</code>. For example, the <a href="http://es5.github.io/#x15.4.4.6" rel="nofollow">pop method</a> always removes the <code>length-1</code>'th element and decrements <code>length</code> by one, no matter how many elements an array actually contains.</p> <p>Also do note that most array methods are generic and don't "know" anything about arrays specifically. They can manipulate arbitrary objects, and if such an object happens to have a property named <code>length</code>, it will be adjusted according to the above rule. Consider:</p> <pre><code>foo = { length: 100, 99: 'hi' } alert([].pop.apply(foo)) // hi alert(foo.length) // 99 alert([].pop.apply(foo)) // undefined alert(foo.length) // 98 </code></pre> <p>That is, in the context of your question it's irrelevant how exactly arrays are represented - <code>pop</code> and friends don't use this information.</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. 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.
 

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