JS - Object undefined
<p>I have this object definition</p>

<pre><code>function Item(id, code, description) {
    this.id = id || "";
    this.code = code || "";
    this.description = description || "";
}
</code></pre>

<p>In my javascript code if I write </p>

<pre><code>var d = new Item('a', 's', 'd');
alert(d.toSource());
</code></pre>

<p>everything is OK</p>

<p>But if I write</p>

<pre><code>var d = new Item('a', 's', 'd');
function getItem(self) {
    ...
    alert(d.toSource());
}
</code></pre>

<p>the variable d is undefinied... What's the problem? var d isn't a global variable as defined?</p>
