JavaScript parseint () function

Source: Internet
Author: User

JavaScript parseint () function

JavaScript Global Objects

Definition and usage

The parseint () function parses a string and returns an integer.

Grammar
parseint (stringradix)
Parameters Description
String Necessary. The string to be parsed.
Radix

Optional. Represents the cardinality of the number to parse. The value is between 2 and 36.

If this argument is omitted or its value is 0, the number is parsed based on 10. If it starts with "0x" or "0X", it will have a base of 16.

If the parameter is less than 2 or greater than 36, parseint () returns NaN.

return value

Returns the parsed number.

Description

When the value of the parameter radix is 0, or if the parameter is not set, parseint () determines the cardinality of the number based on string .

For example, if string starts with "0x", parseint () resolves the remainder of the string to a 16-binary integer. If string starts with 0, then ECMAScript V3 allows an implementation of parseint () to parse subsequent characters into octal or hexadecimal digits. If string starts with a number from 1 to 9, parseint () parses it into a decimal integer.

JavaScript parseint () function

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.