FAQ Topic - Why does K = parseInt('09') set K to 0? (2013-05-20)
4 views
Skip to first unread message
FAQ server
unread,
May 19, 2013, 7:00:01 PM5/19/13
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
-----------------------------------------------------------------------
FAQ Topic - Why does K = parseInt('09') set K to 0?
-----------------------------------------------------------------------
Method `parseInt` generally needs a second parameter, `radix`,
for the base (from 2 to 36).
If `radix` is omitted, the base is determined by the contents of
the string. Any string beginning with `'0x'` or `'0X'` represents a
hexadecimal number. A string beginning with a leading 0 may be parsed as
octal (as if `raxix` were 8), in ECMA-262 Ed 3 (octal digits are `0-7`).
If string `'09'` is converted to `0`.
To force use of a particular base, use the `radix`
parameter: `parseInt("09", base)`.