WeChat applet toFixed (tofixed) detailed introduction, the applet toFixed

Source: Internet
Author: User

The small program toFixed (tofixed) detailed introduction, the small program toFixed

The applet retains decimal places (toFixed)

I have encountered many problems today, but the problem is small.The applet retains decimal places (toFixed)Knowledge:

1. Retain the digits after the decimal point.

The method is very simple. toFixed (). The number in the brackets indicates the number of reserved digits. If it is an integer, it will not be 0



Special note: The returned result is a String. I didn't know it at first. I used the return value for addition. After half an hour, I had to spell the String and asked Huang xiujie about the error. the value is obtained only when the parseInt () type is used.


2. Get the number of digits toPrecision ()

The first group gets four digits, and the second group gets six digits.


Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

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.