JsparseInt converts the number at the beginning of the string to int.

Source: Internet
Author: User
ParseInt converts the numbers at the beginning of the string to int. If the start is not a number, NaN parseInt is returned to convert the numbers at the beginning of the string to int. If the start is not a number, NaN is returned.

Definition and usage
The parseInt (string, radix) function parses a string and returns an integer.

This function has two parameters. The first parameter is the string to be parsed. this parameter is required. The second parameter indicates the base number of The number to be parsed, if this parameter is omitted or its value is 0, the number is parsed based on 10. If it starts with "0x" or "0X", it will base on 16.
If this parameter is smaller than 2 or greater than 36, parseInt () returns NaN.

Tips and comments
Note: Only the first digit in the string is returned.
Note: spaces at the beginning and end are allowed.
Tip: if the first character of a string cannot be converted to a number, parseFloat () returns NaN.

Instance:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.