Definition and usage of parseFloat (parameter 1, parameter 2) in js and precautions _ basic knowledge

Source: Internet
Author: User
I used parseFloat (first parameter, 10) When I was reading jquery today. I was very confused about the two parameters. So I collected the information and shared it with you, I hope this article will help you. If you are interested, you can understand that parseFloat (the first parameter, 10) is used in jquery today ), I have never understood what the second parameter means, so I checked it online and wrote it down if I forget it later.

Definition and usage: The parseFloat () function parses a string and returns a floating point number.

Syntax: parseFloat (string). The string parameter is required, indicating the string to be parsed.
Return Value: return the parsed number.

Notes:
1. spaces at the beginning and end are allowed.
2. If the first character of a string cannot be converted to a number, parseFloat () returns NaN
3. If you only want to parse the integer part of a number, use the parseInt () method.
4. Only the first digit in the string will be returned.

Attached example:

The Code is as follows:


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.