Home  >  Article  >  Web Front-end  >  JS examples of adding and removing thousandths_javascript skills

JS examples of adding and removing thousandths_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:29:141655browse
Copy code The code is as follows:

function commafyback(num)
{
var x = num.split(',');
return parseFloat(x.join(""));
}
function commafy(num)
{
num = num.toFixed(2 ) "";
var re=/(-?/d )(/d{3})/
while(re.test(num)){
num=num.replace(re," $1,$2");
}
return num;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn