Q:

Why does Javascript parseInt('0x4A') return the same as parseInt('0x4Avv')?

Why does Javascript parseInt('0x4Avv') return the same as parseInt('0x4A')
I was counting on parseInt('0x4Avv') to return NaN. 
Is there anyway to make it behave as such? 
Even weird strings 'work', e.g: parseInt('0x4Av--9-0-90v') yields the same result as parseInt('0x4A')
Observed in all browsers....

A:

Here is an excerpt from the MDN parseInt documentation

If parseInt encounters a character that is not a numeral in the
  specified radix, it ignores it and all succeeding characters and
  returns the integer value parsed up to that point. parseInt truncates
  numbers to integer values. Leading and trailing spaces are allowed.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
There isn't a built in way to make it behave otherwise, but you could conceivably write your own int parsing function using regex that could be more strict.

A:

The parseInt() function doesn't care about trailing garbage in the source string. The parseFloat() function shares that behavior.
If you want to convert a string to a number and do so in such a way as to ensure the string was "all number", you can use the + unary operator:
var num = +someString;

That gives you a JavaScript number, so if you want an integer you can instead use one of these:
var intval = ~~someString;
var intval = someString|0;

Feeding bad strings as in your examples to any of those techniques will leave you with NaN.

A:

parseInt ignores everything after an invalid number.
Here's is a little example of it behavior.
parseInt("12ab") // radix asumed to 10 since there isn't specified.
// 1 -> valid number
// 2 -> valid number
// a -> not valid number, DROP everything after this including this..
//
// so it endup behaving like:
parseInt("12") // 12

