Application of JavaScript Parseint method.

xiaoxiao2021-03-06  57

Today I found that there is no problem with the previous test, which is a JavaScript verification date.

When the date is 2004-12-08, it is used in Parseint (Date.Getdate ()) that is PARSEINT ('08 ').

The return value is 0 after calling this. Finally, the method verification failed. There is no problem in other dates, and after viewing the JavaScript help documentation. Have the following description:

PARSEINT method

Returns an integer that is converted by a string.

PARSEINT (NUMSTRING, [RADIX])

parameter

Numstring

required. To convert a string of numbers.

Radix

Optional. The value of the number of NumString saved between NumString between 2 and 36. If not provided, the prefix is ​​the string of '0x' is used as a hexadecimal, the prefix is ​​a string of '0' is used as an eight-based. All other strings are treated as decimal.

Description

PARSEINT method Returns an integer equal to the numeric value saved in NumString. If the NumString prefix cannot be interpreted as an integer, returns NAN (not a number). Finally, I changed the way to PARSEINT ('08 ', 10). Later, I think Parseint ('08 ') will return 0? I think it should return 10 (just starting everyone like this), in fact, think carefully, this method is to process according to octal, and 8 is never appear in Octa. Therefore, the conversion failed.

转载请注明原文地址:https://www.9cbs.com/read-83260.html

New Post(0)