Forums > Javascript

parseInt

August 31, 2011 | 8:32 pm

Hi,

I don’t get it. I got the following script:
test="05A";
post ("test is ");
post (test,"n");
post ( parseInt(test.slice(0,2)), "n");
test="08A";
post ("test is ");
post (test,"n");
post ( parseInt(test.slice(0,2)), "n");

This gives me the following output:
js: test is 05A
js: 5
js: test is 08A
js: 0

Why doesn’t the second output give me 8?

Cheers


August 31, 2011 | 9:23 pm

Never mind. This:
post ( parseInt(test,10), "n");
works


Viewing 2 posts - 1 through 2 (of 2 total)