This is a common Javascript gotcha with a simple solution:
Just specify the base, or ‘radix’, like so:
parseInt('08',10); // 8
You could also use Number:
Number('08'); // 8
More Related Contents:
- I need a Javascript REGEX for Integers between 18 and 140 inclusive [closed]
- Generate unique random numbers between 1 and 100
- How to print a number with commas as thousands separators in JavaScript
- Generating random whole numbers in JavaScript in a specific range
- How to convert a string to an integer in JavaScript?
- Does JavaScript support 64-bit integers?
- Check if a number has a decimal place/is a whole number
- How does x|0 floor the number in JavaScript?
- Extremely large numbers in javascript
- bitwise AND in Javascript with a 64 bit integer
- Sort an array based on another array of integers
- Round number up to the nearest multiple of 3
- Whats the difference between JS Number.MAX_SAFE_INTEGER and MAX_VALUE?
- Convert integer into its character equivalent, where 0 => a, 1 => b, etc
- Convert boolean result into number/integer
- Integers in JavaScript
- Why are Octal numeric literals not allowed in strict mode (and what is the workaround?)
- Does Javascript handle integer overflow and underflow? If yes, how?
- Does normal javascript works on node – webkit or not? [closed]
- How to find content of a specific cell with row and column index?
- What are the nuances of scope prototypal / prototypical inheritance in AngularJS?
- How can I update the parent’s state in React?
- JavaScript ES6 promise for loop
- How to get the last character of a string?
- What is the best JavaScript code to create an img element
- When is the ‘javascript:’ prefix valid syntax?
- How are JavaScript arrays implemented?
- React Error: “SharedArrayBuffer is not defined” in Firefox
- MediaElementAudioSource outputs zeroes due to CORS access restrictions
- How to replace the entire html webpage with ajax response?