Hi Richard,
Thanks for the pointer. I was unaware of the possibility of 'undefined'.
Flanagan states "undefined is returned when you use either a variable that
has been declared but never had a value assigned to it or an object property
that does not exist" - (5th ed.)
How will your solution behave if for some reason this.north is assigned null?
Regards,
Steve
-----Original Message-----
From: Software Improvements gn-devel [mailto:gn-devel@anonymised.com]
Sent: Thursday, 9 October 2008 9:01
To: geonetwork-devel@lists.sourceforge.net
Subject: Re: [GeoNetwork-devel] Probable bug in intermap script im_class.js
[SEC=UNCLASSIFIED]
Stephen.Davies@anonymised.com wrote:
> It seems to me that there is a bug in the intermap script, im_class.js.
>
> The bug appears at line 178, in the function getURLbbox. The code
fragment:
>
>
>
> if(this.north)
>
> return MapUtils......
>
> else
>
> return null;
>
>
>
> will return null if this.north has the value null OR if this.north is
0 (i.e. the equator).
In my own working copy I had already changed the test to:
if(this.north != undefined)
It "works for me". The differences between
null and undefined are subtle and even
after reading the section in Flanagan's
book several times I'm still not sure
which one is the "right" one to use here.
--
Richard Walker
Software Improvements Pty Ltd
Phone: +61 2 6273 2055
Fax: +61 2 6273 2082
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at
http://sourceforge.net/projects/geonetwork
Stephen.Davies@anonymised.com wrote:
Flanagan states "undefined is returned when you use either a variable that
has been declared but never had a value assigned to it or an object property
that does not exist" - (5th ed.)
How will your solution behave if for some reason this.north is assigned null?
Haven't tried it.
Flanagan (5th ed.) says on p. 67 in the discussion
of the rules for the == operator:
-- If one value is null and the other is undefined,
they are equal.
So maybe testing equality (or non-equality) against
null and against undefined behave (or, should
behave) identically?
Note, === would behave differently from == here;
=== is the "real" comparison operator.
(But the comparison operator should be =, not
== or ===. Sigh.)
Assuming Flanagan accurately represents
how JS works -- and I have no reason to
doubt that -- I'd say his book is a rich
resource if you're looking for
six impossible things to believe before
breakfast.
--
Richard Walker
Software Improvements Pty Ltd
Phone: +61 2 6273 2055
Fax: +61 2 6273 2082
Software Improvements gn-devel wrote:
Stephen.Davies@anonymised.com wrote:
Flanagan states "undefined is returned when you use either a variable that
has been declared but never had a value assigned to it or an object property
that does not exist" - (5th ed.)
How will your solution behave if for some reason this.north is assigned null?
Haven't tried it.
Flanagan (5th ed.) says on p. 67 in the discussion
of the rules for the == operator:
-- If one value is null and the other is undefined,
they are equal.
So maybe testing equality (or non-equality) against
null and against undefined behave (or, should
behave) identically?
Have now tried it; I can confirm you can use either
if(this.north != undefined)
or
if(this.north != null)
to achieve the same result.
But it turns out the latter is "better",
because whereas "null" is a reserved word,
"undefined" is not, which means its
"value" can be changed!
See e.g.,
http://hexmen.com/blog/2007/01/undefined-is-not-a-reserved-word/
for a discussion.
And for the sake of completeness,
there's also the void operator;
if(this.north != void 0)
would work just as well.
--
Richard Walker
Software Improvements Pty Ltd
Phone: +61 2 6273 2055
Fax: +61 2 6273 2082