From: David Mark on
On Jul 29, 5:35 am, Ry Nohryb <jo...(a)jorgechamorro.com> wrote:
> On Jul 29, 11:22 am, David Mark <dmark.cins...(a)gmail.com> wrote:
>
>
>
> > For one, you are looking at the wrong specifications as we are
> > discussing language features.
>
> The Global Object is a language feature, the 'window' symbol is not.

Yes, exactly. And you brought it into the discussion where it had no
place. ;)

From: David Mark on
On Jul 29, 5:32 am, Ry Nohryb <jo...(a)jorgechamorro.com> wrote:
> On Jul 29, 11:22 am, David Mark <dmark.cins...(a)gmail.com> wrote:
>
>
>
>
>
> > On Jul 29, 5:10 am, Ry Nohryb <jo...(a)jorgechamorro.com> wrote:
>
> > > On Jul 29, 10:53 am, David Mark <dmark.cins...(a)gmail.com> wrote:
>
> > > > I expected better from you, El Abuelo.  Every time I give you the
> > > > slightest shred of credit, you make me regret it.
>
> > > We don't have to agree, Mark, so don't worry.
>
> > Worry about what?
>
> > > I saw the "This section is not normative." in bold in there. But,
> > > there's so many that aren't normative -yet- in the browsers...
>
> > The section it refers to in the *language specification* is not
> > normative either.
>
> > >http://google.com/search?q="This+section+is+not+normative"site=w3.org
> > > --> About 416 results
>
> > And?
>
> > > Say, e.g. the timers, the navigator object, the XHRs... don't you use
> > > them ?
>
> > For one, you are looking at the wrong specifications as we are
> > discussing language features.  For two, there is no standard DOM
> > specification for the window object anyway.
>
> > > Well, you shouldn't: they're not in any standard! (maybe
> > > they've been finally standardized recently (?)).
>
> > You don't get it.  Don't use something that has no formal
> > specification if there is a standard alternative.  And certainly don't
> > make assumptions about host objects when you don't have to.  ;)
>
> Since when is the Global Object a host object? :-)

Since never, Jorge. Are you trying to be funny?
From: Sean Kinsey on
On Jul 29, 4:51 am, RobG <rg...(a)iinet.net.au> wrote:
> I stumbled across a function that tests if a global variable exists or
> not, my version of the code is below. Other than the obvious
> irrelevance of such a function (a simple typeof test should be
> sufficient in every case I can imagine), and that the use of
> try..catch and eval should be limited as much as possible, are there
> any significant issues with it?
>
>   function doesGlobalVarExist(v) {
>
>       try {
>           eval(v);
>           return true;
>
>       } catch(e) {
>           return false;
>       }
>   }

Isn't the biggest problem with this (and any eval-like solution) that
it isn't without side effects?
What if the variable you are checking contains executable code?
var foo = 'alert("foo")';
doesGlobalVarExist(foo); // alerts foo;


And if the only goal here is to test if a variable has a value, then
typeof is the proper way to go as both null and undefined will eval
just fine and result in true being returned from the above function.
From: Ry Nohryb on
On Jul 29, 11:45 am, David Mark <dmark.cins...(a)gmail.com> wrote:
> On Jul 29, 5:35 am, Ry Nohryb <jo...(a)jorgechamorro.com> wrote:
>
> > On Jul 29, 11:22 am, David Mark <dmark.cins...(a)gmail.com> wrote:
>
> > > For one, you are looking at the wrong specifications as we are
> > > discussing language features.
>
> > The Global Object is a language feature, the 'window' symbol is not.
>
> Yes, exactly.  And you brought it into the discussion where it had no
> place.  ;)

The w3 site is the right place to show you where to read that the
'window' symbol (not a language feature) that you believe to be a host
object (it's the object that implements the Window interface) is in
fact ("for some languages, such as ECMAScript") the Global Object
("the object that provides the global namespace for script
execution"), which is not a host object -but you seem to believe it
is-.

Now, next, come and tell me that it is in IEs, so that I can ROTFLOL.
--
Jorge.
From: Ry Nohryb on
On Jul 29, 11:56 am, Sean Kinsey <okin...(a)gmail.com> wrote:
>
> Isn't the biggest problem with this (and any eval-like solution) that
> it isn't without side effects?
>
> What if the variable you are checking contains executable code?
>     var foo = 'alert("foo")';
>     doesGlobalVarExist(foo); // alerts foo;

True.

> And if the only goal here is to test if a variable has a value, then
> typeof is the proper way to go (...)

ISTM that typeof does not reveal "has a value" properly because a var
that exists might hold the value undefined, and typeof would return
undefined too for a var that does not exist. As the topic of this
thread is "does global variable exist", I'd say that typeof is not the
proper solution.
--
Jorge.