SoFunction
Updated on 2025-03-03

js parseInt("08") does not specify carry system problem

js parseInt("08") does not specify carry system problem

Updated: June 19, 2010 12:39:40 Author:
Today, I am making JS judgment about the month. I can get the correct result for parseInt("01") to parseInt("07"); but if it is parseInt("08") or parseInt("09"), it returns 0. First, look at parseInt syntax: parseInt(string, radix);
where string is the string to be converted, and radix is ​​binary, octal, hexadecimal or decimal.
When radix is ​​not specified by default, when the 0x switch is switched, it is hexadecimal; if the 0 switch is switched and the second bit is not x, then it is octal (because the octal cannot have 8, 9, an error returns 0).
Therefore, when we use it, we should clearly specify the carry system to prevent errors.
If we usually use decimal bits, we will parseInt("08", 10);
  • js
  • parseInt

Related Articles

  • js load reading content and display and hide div examples

    This article mainly introduces how to load and read content and display and hide divs by js. Friends who need it can refer to it
    2014-02-02
  • What does javascript:void(0) mean and the difference between href=# and href=javascriptvoid(0)

    In Javascript, void is an operator. This operator specifies that an expression is to be calculated but does not return a value. This article introduces to you what javascript:void(0) means and the difference between href=# and href=javascriptvoid(0). Please refer to it if you need it.
    2015-11-11
  • Analysis of the difference between JS data types (basic data types, reference data types) and heap and stack

    This article mainly introduces the differences between JS data types (basic data types, reference data types) and heap and stack. It analyzes the JS basic data types, reference data types concepts, usage, and the differences between heap and stack in combination with examples. Friends who need it can refer to it.
    2020-03-03
  • Knockoutjs Learning Series (II) Fancy Bundle

    This article mainly introduces the relevant information of the Knockoutjs learning series (II) fancy bundling, and mainly introduces the use of various bindings in knockoutjs. It is very good and has reference value. Friends who need it can refer to it.
    2016-06-06
  • Discuss the similarities and differences of three ways of declaring global variables in JavaScript

    This article mainly introduces the similarities and differences of three ways to declare global variables in JavaScript. Variables and variable declarations are the most basic concepts of a language that beginners will quickly master. Friends who need it can come and refer to it, I hope it will be helpful to everyone
    2013-12-12
  • Countdown to register 60s for WeChat applets using JS to realize the countdown to register 60s for WeChat applets

    This article mainly introduces the 60s countdown function of WeChat applet registration, as well as the 60s countdown function of using JS to realize the 60s countdown function of registration, which has certain reference value. Interested friends can refer to it.
    2017-08-08
  • bootstrap multiple styles of progress bar display

    This article mainly shows everyone the various styles of bootstrap progress bars, default progress bars, striped progress bars, etc., which have certain reference value. Interested friends can refer to it.
    2016-12-12
  • A brief discussion on the neat way of JavaScript code

    This article mainly introduces a brief discussion on the neat way of JavaScript code. The editor thinks it is quite good. I will share it with you now and give you a reference. Let's take a look with the editor
    2018-10-10
  • JS implements simple magnifying glass effect

    This article mainly introduces in detail the effect of JS to implement a simple magnifying glass, which can be changed at will, and the size and proportion of the magnification area are introduced in detail. The sample code in the article is very detailed and has certain reference value. Interested friends can refer to it.
    2021-09-09
  • Layui implements the method of moving the mouse to a cell to display data

    Today, the editor will share with you a method of using Layui to move the mouse to a cell to display data. It has good reference value and hope it will be helpful to everyone. Let's take a look with the editor
    2019-09-09

Latest Comments