


Summary of using javaScript parseInt character to number function_Basic knowledge
May 16, 2016 pm 06:42 PMI found a problem during the test today. When the month in the database is 09, there is a problem. After using parseInt to convert it, it becomes 0. So puzzled. After testing for a long time, no problem was found in my code. I searched it on Google and found out what it was.
For parseInt("01") to parseInt("07");parseInt("10"), the correct result can be obtained, but if it is parseInt("08") or parseInt("09 ") returns 0; First, look at the parseInt syntax: parseInt(string, radix); If the following parameters are not written, use the beginning of the first one to determine where string is the string to be converted, and radix is binary, octal, or hexadecimal. or decimal. When radix is not specified by default, when it is switched with 0x, it is hexadecimal; if it is switched with 0 and the second digit is not x, it is octal (because octal cannot have 8 or 9, so an error is reported and 0 is returned) . If it starts with 1, it is in decimal, so after 10, it is correct again. Therefore, we should clearly specify the carry system when we use it to prevent errors. If we usually use decimal digits, we use parseInt("08", 10);
So, it is wrong. When using it in the future, it is best to add the decimal number after the parseInt function to ensure that there is no error. Otherwise, there will be a delay of several hours. ! ! ! ! ! ! ! ! ! !

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement an online speech recognition system using WebSocket and JavaScript

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems

How to implement an online reservation system using WebSocket and JavaScript

How to use JavaScript and WebSocket to implement a real-time online ordering system

Simple JavaScript Tutorial: How to Get HTTP Status Code

JavaScript and WebSocket: Building an efficient real-time weather forecasting system

How to get HTTP status code in JavaScript the easy way

What are the platforms for virtual currency trading around the world? The top ten latest 2025 digital currency app rankings
