identifier lookup conundrum
<p>I understand why the following alert() returns "blue". </p>

<pre><code>var color = "blue";
function getcolor () {
return color;
color = "red";
}
alert(getcolor());
</code></pre>

<p>If i'm not incorrect, the function stops executing after its return statement, preventing the global "color" variable from being overwritten.</p>

<p>But why, if we change the function's definition to that below, does the alert() return "undefined"?</p>

<pre><code>var color = “blue”;
function getcolor () {
return color;
var color = “red”;
}

alert(getcolor());
</code></pre>

<p>I expected that the getcolor() function would exit after the return statement, as before, and return the value of the global color variable "blue".</p>
