0

Possible Duplicate:
Why does parseInt(“09”) return 0 but parseInt(“07”) return 7?

I have a string like (10) | (01)

I want convert to int.

I use this code

parseInt("10") ----> 10
parseInt("07") ----> 7

but when i use this code for (08) , it is convert to (0)

Community
  • 1
  • 1
ar.gorgin
  • 4,403
  • 10
  • 55
  • 94

1 Answers1

2

If a string begins with 0 the default radix is 8.

Try specifying the radix explicitly:

parseInt("08", 10)
kapa
  • 75,446
  • 20
  • 155
  • 173
Joe
  • 118,426
  • 28
  • 194
  • 329