Use this:
if(parseInt(x, 10)!=parseInt(y, 10))
If you do not specify the radius, "09" is parsed as octal (this gives 0).
MDN documentation about parseInt
Note that you should not rely on this interpretation when dealing with octal representations:
ECMAScript 5 removes octal interpretation
The ECMAScript 5 specification of the parseInt function no longer allows implementations to process strings starting with the character 0 as octal values. ECMAScript 5 says:
The parseInt function produces an integer value, determined by the interpretation of the contents of the string argument according to the specified radius. Exceeding a space in a line is ignored. If radix is ββundefined or 0, it is assumed that it is 10, except when a number begins with pairs of characters 0x or 0X, in which case a radius of 16 is assumed to be. If radix is ββ16, the number may also optionally begin with a pair of 0x or 0X characters.
This is different from ECMAScript 3, which discourages but allows octal interpretation.
Since many implementations have not used this behavior since 2011, and since older browsers must be supported, always specify a radius.
Simply:
always indicate radius
source share