title: Why do class embedded loops appear to follow different assignment rules?
body: <p>Alright so here's a class with a six item array in the constructor.</p>
  
  <pre><code>class forLoopProblem {
  
    constructor() {
      this.a = [5,8,7,4,6,18];
    }
  </code></pre>
  
  <p>What I want to do is use the length of the array to limit the number of iterations in the <code>for</code> loop below</p>
  
  <pre><code>  iterate(ap1) {
      for (i = 0; i &lt;= this.a.length; i++) {
        console.log(i);
      }
    }
  }
  
  var internalVar = new forLoopProblem();
  </code></pre>
  
  <p>Unfortunately <code>internalVar.iterate()</code> produces an exception stating that <code>a</code> is not defined.</p>
  
  <pre><code>  log() {
      console.log(this.a.length);
      console.log(this.a);
    }
  }
  
  var internalVar = new forLoopProblem();
  </code></pre>
  
  <p>But if <code>a</code> is not defined then why does <code>internalVar.log()</code> behave as expected, printing <code>6</code> along with the contents of the array to the console?</p>
  
  <p>At first I thought perhaps <code>6</code> is a string that needs to be converted to an integer before the loop assignment will recognize it. So I tried <code>parseInt()</code> but that didn't work. And anyway the exception says that the variable isn't defined, so I don't think it's a parsing issue.</p>
  
  <p>I can even use <code>a</code> to assign the initial iteration variable to 6, like so:</p>
  
  <pre><code>    for (i = this.a.length; i &lt;= 10; i++) {
  </code></pre>
  
  <p>to produce <code>6</code>,<code>7</code>,<code>8</code>,<code>9</code>, and <code>10</code> as console output.</p>
  
  <p>So what gives with the limiter specification?</p>