That’s because “09” is an invalid number, in octal.
The parseInt() funciton acutally has 2 arguments that most people are not aware of, first is the string to parse and then a radix (which is optional). The radix value allows you to convert a binary (base 2), hexadecimal (base 16) or other base string to a decimal integer.
Example: parseInt(“FF”, 16); returns 255
If you code
var x = 0x18;
it will display 24 which is the decimal equivalent of the hex number “18”. Likewise,
var x = 014;
displays 12 which is the decimal value of the octal number “14”.
Hexadecimal uses the numbers 0 to 9 and the letters A to F, 16 in all. You would normally see hexadecimal values used for colors (Orange: #FF9C00, White: #FFFFFF, or Red: #FF0000). Octal is base 8, so only the numbers 0-7 are valid. Hence, “09” is not a valid octal number and the function returns 0. Just as it would for “abc” in decimal … it’s not a valid number.
To avoid this, get into the habit of always adding the second argument, in this case …
returns 9 (decimal), as desired.