title: Iterating String.split() working differently than I expected
body: <p>I am writing a simple javascript code to parse, and verify a chess position written in Forsyth–Edwards Notation (FEN).</p>
  <p>The default chess position in this notation is given by,</p>
  <p><code>const defaultFEN = &quot;rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1&quot;;</code></p>
  <p>There are 6 components, I split the components by whitespace using String.split(&quot; &quot;), I now want to further split the first element of the resulting array by &quot;/&quot;, which will give the state of each rank.</p>
  <p>Running this code gives me an unintuitive result...</p>
  <pre><code>const defaultFEN = &quot;rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1&quot;;
  const locations = defaultFEN.split(&quot; &quot;)[0];
  
  for (let rank in locations.split(&quot;/&quot;)) {
     console.log(rank);
  }
  </code></pre>
  <p>I expected the output to be 8 Strings, delimited by &quot;/&quot;, in the first portion of the defaultFEN string. Instead I get the numbers 0-7 printing out.</p>
  <p>Interestingly, If I manually access this array, <code>console.log(locations.split(&quot;/&quot;)[i])</code>, for any number i in the interval [0-7], I see the result I intended.</p>
  <p>Why are the numbers 0-7 printing out when using the iterative loop, but it works exactly as intended if I use a normal index based for loop?</p>