How does JavaScript's in object feature work?
<p>I am learning JavaScript and something I cannot understand at the moment is this example below.  Using <code>in</code> to check if an item exist in the Object on the right side.  </p>

<p>This code will merge user options into default options.</p>

<p>What is confusing to me is the <code>i</code> is not defined anywhere, so how does it know what <code>i</code> is?<br>
If I print out <code>i</code> inside of the <code>for</code> block, it lists every <code>option</code> of my object.</p>

<p>I have read <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/in" rel="nofollow">MDN's article about the <code>in</code> operator</a> but it does not explain this handling of an undefined variable.</p>

<pre><code>var i;
for(i in options) {
  if(i in this.options) {
    this.options[i] = options[i];
  } else {
    throw new Error("Notice doesn't support option: " + i);
  }
}
</code></pre>
