From: John G Harris on
On Mon, 2 Aug 2010 at 00:26:59, in comp.lang.javascript, David Mark
wrote:

<snip>
>Math was mentioned as a counter-example (though it is not a global
>variable).
<snip>

Math is a property of the global object. The global object is the
variable object for global vars and functions. Math is accessible from
everywhere.

It's global and it's indistinguishable from a variable. It can only be
'not a global variable' with some weird and unnecessary definition of
global variable.

John
--
John Harris
From: David Mark on
On Aug 3, 3:21 pm, John G Harris <j...(a)nospam.demon.co.uk> wrote:
> On Mon, 2 Aug 2010 at 00:26:59, in comp.lang.javascript, David Mark
> wrote:
>
>   <snip>>Math was mentioned as a counter-example (though it is not a global
> >variable).
>
>   <snip>
>
> Math is a property of the global object.

Doesn't that go without saying?

> The global object is the
> variable object for global vars and functions. Math is accessible from
> everywhere.

And that.

>
> It's global and it's indistinguishable from a variable.

It is certainly not indistinguishable from a variable.

> It can only be
> 'not a global variable' with some weird and unnecessary definition of
> global variable.

That's nonsense.
From: John G Harris on
On Wed, 4 Aug 2010 at 00:58:32, in comp.lang.javascript, David Mark
wrote:
>On Aug 3, 3:21�pm, John G Harris <j...(a)nospam.demon.co.uk> wrote:

<snip>
>> It's global and it's indistinguishable from a variable.
>
>It is certainly not indistinguishable from a variable.

How so ?


>> It can only be
>> 'not a global variable' with some weird and unnecessary definition of
>> global variable.
>
>That's nonsense.

What is your reasoning ?

John
--
John Harris
From: John G Harris on
On Wed, 4 Aug 2010 at 17:36:28, in comp.lang.javascript, Lasse
Reichstein Nielsen wrote:
>John G Harris <john(a)nospam.demon.co.uk> writes:

<snip>
>> How so ?
>
>Well, it depends on what a (global) variable is. Let's for a moment
>assume it's something declared using "var" or "function" in the global
>scope.

Let's for ever assume it's anything held in a variable object.

Then you can introduce a classification of variables :
Var variables
(with sub-classes declared, implicit)
Function declaration variables
Predefined variables
(with sub-classes primitive, function object, other object)


<snip>
>> What is your reasoning ?
>
>Probably "If I not say this is a variable, this not be a variable!" :P
>More seriously, what is needed isn't the reasoning, but just stating
>what it means to be "a global variable". After that, it's a matter
>of reading to spec to see if Math is one or not, or possibly just
>disagreeing with the defintion.

ECMA262 doesn't define 'variable'.

Are you bidding to be the second PointedEars ?

John
--
John Harris
From: David Mark on
On Aug 4, 6:28 am, John G Harris <j...(a)nospam.demon.co.uk> wrote:
> On Wed, 4 Aug 2010 at 00:58:32, in comp.lang.javascript, David Mark
> wrote:
>
> >On Aug 3, 3:21 pm, John G Harris <j...(a)nospam.demon.co.uk> wrote:
>
>   <snip>
>
> >> It's global and it's indistinguishable from a variable.
>
> >It is certainly not indistinguishable from a variable.
>
> How so ?

Did you declare it in your code? If so, it's a variable. If not,
it's not. And yes, I am using the term "declare" loosely. Named
arguments and function expressions (the latter of which should be
avoided) count.

The only gray area would be implied global "variables", which are used
without declaration and create properties on the Global Object (which
differ slightly from those created by properly declared global
variables).

Built-in objects, host objects, etc. are not variables. Calling them
as such serves only to create confusion (and there is enough of that
as it is).