Thomas 'PointedEars' Lahn
J.R. said:Considering only the given code by Cal, it creates two implied global
variables (w and h),
No. What happens is what I described, which is compliant with ECMAScript
Edition 3 Final, sections 11.13.1 and 8.6.2, and Editions 5 and 5.1,
sections 11.13.1 and 8.7.2, respectively.
according to ECMA-262 3rd, section 12.2:
The current edition of ECMAScript is 5.1, June 2011 CE; not Edition 3
(Final), December 1999/March 2000 CE.
"If the variable statement occurs inside a FunctionDeclaration, the
variables are defined with function-local scope in that function, as
described in s10.1.3. Otherwise, they are defined with *global scope*
(that is, they are created as members of the global object, as described
in 10.1.3) [...]"
That section's second sentence refers to *variable statements* outside of a
FunctionDeclaration, as made obvious by its first sentence.
As written above, the correct terminology is indeed "variable defined in
the function-local scope".
No, a "variable defined *with* function-local scope" is something else than
"a variable defined *in* the function-local scope" (which you also did not
say before). The proper term for such a variable is _local_ variable, _not_
a "private" variable (whereas you said the latter before).
ACK, except for the *only*.
Please name a counter-example using ECMAScript-conforming code where a
`private'-like property visibility is achieved explicitly.
It's not wrong, it's a different approach instead.
No, it is wrong to say "must not use". "Must not" in English means "is not
allowed to". It is certainly allowed to use that syntactical construct, as
it constitutes nothing more than consecutive statements.
ECMAScript permits using either a single var or many var statements as one
That is not what you said before.
I prefer the single var pattern.
That is also not what you said before.
Will you please at least *try* get yourself educated before you post?
Personally, I prefer Python / Django but it doesn't matter to this
those syntactical constructs.