title: Why does parseInt('dsff66',16) return 13?
body: <p>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.</p>
  
  <p>My call was:<div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var parsed = parseInt('dsff66', 16); // note the 's' in the first argument
  document.write(parsed);</code></pre>
  </div>
  </div>
  </p>
  
  <p>and the result was: <code>13</code>.</p>
  
  <p>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 <code>parseInt('fg',16)</code> I would get <code>15</code> as a result.</p>
  
  <p>In my opinion, it should return NaN. Can anyone explain to me why it doesn't? Why would anyone want this function to behave like this (return an integer even if it isn't the precise representation of the string passed) ?</p>