JS, what functions can make a number per thousand add a "," and what functions can be retained after the decimal two digits
Source: Internet
Author: User
I have not found such a function in JS <br>
<br>
I used to make up a truncated decimal function, the code is as follows <br>
<br>
/***********************************************************<br>
Function FormatNumber (value,num) <br>
Written by zergling<br>
The JavaScript version of the FormatNumber function is the same as VBScript, the first parameter is the value to be formatted, and the second is the number of decimal places to keep <br>
Note: The string type is returned <br>
/<br>
function FormatNumber (value,num) <br>
{<br>
var a,b,c,i<br>
a = value.tostring ();<br>
b = A.indexof ('. '); <br>
c = a.length;<br>
if (num==0) <br>
{<br>
if (b!=-1) <br>
a = a.substring (0,b);<br>
} <br>
else<br>
{<br>
if (b==-1) <br>
{<br>
a = a + ". "; <br>
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.