JRS: In article <op*****************@news.optusnet.com.au>, seen in
news:comp.lang.javascript, Robert Mark Bram <re********@remove.this.optu
snet.com.au> posted at Thu, 1 Jan 2004 17:04:00 :-
I know I can test like this:
if (isNaN("blah"))
But when I try this it doesn't work:
if ("blah" == Number.NaN)
What am I doing wrong?
Using the second method instead of the first. Deciding that you know
what the second should do without reference to adequate documentation.
A NaN is not equal to anything at all, not even to another NaN generated
the same way, or to a copy of itself.
One use of this, BTW, is in dealing with a user-given range. If the
test is carefully arranged, it can give the desired result with NaN :
if (!(Y2-Y1<26) || Y1>Y2) { // does NaN
DynWrite(Div, "<b>Bad Range<\/b>") ; return }
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.