Re: Cookie problem! Getting error when passing the expire date.
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Cookie problem! Getting error when passing the expire date.

From: Lasse Reichstein Nielsen <lrn@hotpop.com>
Date: Sun Apr 30 2006 - 20:21:41 CEST

"Evertjan." <exjxw.hannivoort@interxnl.net> writes:

> Lasse Reichstein Nielsen wrote on 30 apr 2006 in comp.lang.javascript:

>> function toNumberWithDefault(x,def) {
>> var n = Number(x);
>> return isNaN(n) ? def : n;
>>}
>
>
> alert(toNumberWithDefault('',7777)) // alerts 0

I guess it's a matter of definition whether "" represents a number
(that would be 0 then) or not. The "Number" function appears to think
it does.

If one wants a clearly defined set of number strings to be converted
to numbers, then the format of the string should be tested before
using any standard conversion function, since all standard functions
seem to have the odd case :)

/L

-- 
Lasse Reichstein Nielsen  -  lrn@hotpop.com
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'
Received on Mon May 1 05:28:02 2006