Why does parseInt('dsff66',16) return 13?
today I stumbled on a strange (in my opinion) case in JavaScript. I passed a non-hexadecimal string to the parseInt function with the base of 16 and...I got the result. I would expect the function to throw some kind of exception or at least return NaN, but it succeeded parsing it and returned an int. My call was: var parsed = parseInt('dsff66', 16); // note the 's' in the first argument document.write(parsed); and the result was: 13 . I noticed that it "stops" parsing with the first character that doesn't belong to the numeral system specified in the 2nd argument, so calling parseInt('fg',16)