ParseInt treats its first argument as a string which means first of all Infinity.toString() is called, producing the string "Infinity". So it works the same as if you asked it to convert "Infinity" in base 19 to decimal. What happens next is that parseInt scans the input "Infinity" to find which part of it can be parsed and stops after accepting the first I (because n is not a valid digit in base 19).
Therefore it behaves as if you called parseInt("I", 19), which converts to decimal 18
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать