ES3.1 Draft: 11 June 2008 version available
Mark S. Miller
erights at google.com
Mon Jun 16 08:39:55 PDT 2008
On Sat, Jun 14, 2008 at 11:43 PM, Garrett Smith <dhtmlkitchen at gmail.com> wrote:
> The spec doesn't mention that FunctionExpression with Identifier can
> affect scope chain. Example:-
>
> (function f() {
> var propertyIsEnumerable = 0;
> (function f() {
> alert(propertyIsEnumerable); //=> native code
> })();
> })();
Hi Garrett, thanks for alerting us to this bizarre behavior. I had no
idea. I did reproduce this behavior and minor variants. However,
oether variants didn't work, indicating that I don't yet understand
what's happening here. For example, on Firefox 2.0.0.14 in squarefree:
var g = function f() { return x; }
g()
ReferenceError on line 1: x is not defined
g.x = 3;
3
g()
ReferenceError on line 1: x is not defined
As I thought I understood this example, I would have expected the last
call to g() to return 3. Can someone explain why it doesn't?
--
Cheers,
--MarkM
More information about the Es4-discuss
mailing list