No, takze je to asi jasne. Popis funkce parseInt sice rika:
The parseInt function produces an integer value dictated by interpretation of the contents of the string argument according to the specified radix. Leading whitespace in the string is ignored. If radix is undefined or 0, it is assumed to be 10 except when the number begins with the character pairs 0x or 0X, in which case a radix of 16 is assumed. Any radix-16 number may also optionally begin with the character pairs 0x or 0X.
Lec samotny popis algoritmu jejiho vypoctu je jeste trochu presnejsi.
...
6. Let R = ToInt32(radix).
7. If R =0,gotostep11.
8. If R < 2 or R > 36, then return NaN.
9. If R = 16, go to step 13.
10. Go to step 14.
11. Let R = 10.
12. If the length of S is at least 1 and the first character of S is “0”, then at the implementation's discretion either let R = 8 or leave R unchanged.
...
Je od nich teda krajne nehezke, ze tohle nechavaj na implementaci a navic jeste to nezmini v lidskym popisu ty funkce. Kazdopadne spravna odpoved je potom 0 nebo 8, ale urcite ne NaN, pokud to dobre ctu. |