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,765
  • 12
  • 61
  • 100

1 Answers1

2

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

Try specifying the radix explicitly:

parseInt("08", 10)
kapa
  • 77,694
  • 21
  • 158
  • 175
Joe
  • 122,218
  • 32
  • 205
  • 338