0

Possible Duplicate:
JavaScript: why does parseInt(1/0, 19) return 18?

Why does parseInt(1/0, 19) evaluate to 18 in Javascript ? I understand 19 in not a permissible radix but still can someone tell how things are working here ?

Community
  • 1
  • 1
anuj_io
  • 2,043
  • 2
  • 13
  • 19

1 Answers1

2

Ah, quick javascript consoling led to the answer:

> 1/0
Infinity
> parseInt("Infinity", 19)
18

parseInt seems to convert the first argument to a string, e.g.:

> parseInt(11, 2)
3

so, it's converting the string "Infinity", which explains everything.

Claudiu
  • 224,032
  • 165
  • 485
  • 680