<div dir="ltr">I've recently run into this question in Stack Overflow:<div><br></div><div><a href="http://stackoverflow.com/q/21008329/1348195">http://stackoverflow.com/q/21008329/1348195</a><br></div><div><br></div><div>

```</div><div><pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.27272605895996px">

<code style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif"><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">function</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent"> f</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">()</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">{</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">
    f </span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">=</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">eval</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">""</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">+</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent"> f</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">);</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">
    console</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">log</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">"Inside a call to f(), f is: \n%s"</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">,</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent"> f</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">);</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">}</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">

f</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">();</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">

console</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">log</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">"After a call to f(), f is: \n%s"</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">,</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent"> f</span><span class="" style="margin:0px;padding:0px;border:0px;font-size:13.63636302947998px;vertical-align:baseline;background-color:transparent">);</span></code></pre>

</div><div>```</div><div><br></div><div>What should the output of the following be?</div><div><br></div><div>I expected `undefined` on both but that's because I'm used to strict mode. IE/Chrome treat this differently from Firefox and to be honest when I checked the spec it boiled down to which context is affected here. </div>

<div><br></div><div>In IE/Chrome the eval is creating `f` inside the context of `f` acting like a function declaration inside. In Firefox it's acting like it's running in the global context.</div><div><br></div><div>

Which is correct?  I've tried to follow 10.4.2 (or 18.2.1 in the ES6 draft which is nice) but I still couldn't figure out what "if there is no calling context means".</div><div><br></div><div>Thanks,</div>

<div>Benjamin Grunebaum</div></div>