[Greasemonkey] Javascript lexical scoping question

Julien Couvreur julien.couvreur at gmail.com
Thu Apr 14 19:18:04 EDT 2005


General javascript question not specific to GM.

In the javascript shell:

> function test() { var internal = 5; this.visible = 6; }
> props(test); 
--> expected: I thought no fields would be listed
--> actual: lists "internal" as one of the fields, but not "visible"

> props(new test()); 
--> only lists "visible", which is what I expected

I've been trying to clarify my understanding of javascript objects,
scopes and closures, but I don't understand why "internal" is visible
in the first test.

Any insight?
Julien


More information about the Greasemonkey mailing list