Yep, it thinks it's octal because of the leading 0. I really loved that
'feature' when I had written some javascript to create barcodes and every so
often it would just put in a zero.
So you have to say parseInt(i,10) to ensure that it knows it is decimal.
-Roy
-----Original Message-----
From: Walter Torres [mailto:walter@t...]
Sent: Tuesday, March 11, 2003 9:49 PM
To: javascript
Subject: [javascript] bug?
Will you guys run this on various browsers and tell me why 8 and 9 are ZERO?
I'm on IE 5.5 SP2 on NT4
for (x=5; x<10; x++)
{
i = '0' + x; // convert to STRING
alert(i + '\n' + parseInt(new Number(i)) + '\n' + parseInt(i));
}
Walter