Wenn man ein decimal parsen möchte, sollte man also parseInt("012", 10) aufrufen.
Siehe dazu auch hier http://www.w3schools.com/jsref/jsref_parseInt.asp
JavaScript parseInt() Function
--------------------------------------------------------------------------------
JavaScript Global Functions
--------------------------------------------------------------------------------
Definition and Usage
The parseInt() function parses a string and returns an integer.
The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number.
If the radix parameter is omitted, JavaScript assumes the following:
•If the string begins with "0x", the radix is 16 (hexadecimal)
•If the string begins with "0", the radix is 8 (octal). This feature is deprecated
•If the string begins with any other value, the radix is 10 (decimal)
Syntax
parseInt(string, radix)
Parameter | Description |
string | Required. The string to be parsed |
radix | Optional. A number (from 2 to 36) that represents the numeral system to be used |
Keine Kommentare:
Kommentar veröffentlichen