Revision 47e92837-1ed5-4fb3-bf68-d5d0227911be - Stack Overflow

Quote from the [`documentation`][1]:

> for..in should not be used to iterate over an Array where index order
> is important. Array indexes are just enumerable properties with
> integer names and are otherwise identical to general Object
> properties. There is no guarantee that for...in will return the
> indexes in any particular order and it will return all enumerable
> properties, including those with non–integer names and those that are
> inherited.
> 
> Because the order of iteration is implementation dependent, iterating
> over an array may not visit elements in a consistent order. Therefore
> it is better to use a for loop with a numeric index (or Array.forEach
> or the non-standard for...of loop) when iterating over arrays where
> the order of access is important.

The key here holding the answer to your question is the following sentence:

> Array indexes are just enumerable properties with integer names and
> are otherwise identical to general Object properties.

And the following sentence sums it up:

> for..in should not be used to iterate over an Array where index order
> is important.

 [1]: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/for...in

AltStyle によって変換されたページ (->オリジナル) /