Hacker News new | ask | show | jobs
by saurik 5092 days ago
That is not equivalent: 1/0 returns +Inf, not NaN. In JavaScript, parseInt(NaN, 19) actually returns NaN, as there are no valid digits below radix 19 in the string "NaN". PHP, in fact, has the same behavior that JavaScript does: if you do parseInt or intval on (NaN, 24) you will get 13511 (23 * 24 * 24 + 10 * 24 + 23) in either language.

Unrelated, it seems like intval(1/0, 19) in PHP also returns 0 because 1) intval returns 0 if given an empty string (JavaScript's parseInt returns NaN if given an empty string) and 2) 1/0 seems to return something hilarious... it converts to "", but gettype() on it returns "boolean"... I sadly don't know PHP well enough to understand what it is ;P.