In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to use the parseInt () function in JavaScript". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use the parseInt () function in JavaScript" can help you solve the problem.
JavaScript parseInt () function
JavaScript Global object reference Manual
Definition and usage
The parseInt () function parses a string and returns an integer.
Syntax parseInt (string, radix) parameter describes that string is required. The string to be parsed. Radix
Optional. Represents the cardinality of the number to parse. The value is between 2 and 36.
If the parameter is omitted or its value is 0, the number is parsed on the basis of 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 when it is not set, parseInt () determines the cardinality of the number based on string.
For example, if string starts with "0x", parseInt () parses the rest of the string into hexadecimal integers. If string starts with 0, ECMAScript v3 allows an implementation of parseInt () to parse subsequent characters into octal or hexadecimal numbers. If string starts with a number from 1 to 9, parseInt () parses it to a decimal integer.
Tips and comments
Note: only the first number in the string will be returned.
Note: spaces at the beginning and end are allowed.
Tip: if the first character of the string cannot be converted to a number, parseFloat () returns NaN.
Example
In this example, we will use parseInt () to parse different strings:
ParseInt ("10"); / return 10parseInt ("19", 10); / / return 19 (10) parseInt ("11", 2); / / return 3 (2) parseInt ("17", 8); / / return 15 (8) parseInt ("1f", 16); / / return 31 (16) parseInt ("010") / / undecided: return 10 or 8 about "how to use the parseInt () function in JavaScript". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.