我正在寻找一种方法来删除逗号和字符串后面的所有内容,例如:
重要的,不那么重要
我想删除",不是那么重要"
有任何想法吗?提前致谢!
我正在尝试创建一个函数,可以格式化一个数字,最小小数位数为2,最大值为4.所以基本上如果我传入354545.33,我会回到354,545.33,如果我传入54433.6559943,我会回来54,433.6559.
function numberFormat(num){
num = num+"";
if (num.length > 0){
num = num.toString().replace(/\$|\,/g,'');
num = Math.floor(num * 10000) / 10000;
num += '';
x = num.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
else{
return num;
}
}
Run Code Online (Sandbox Code Playgroud) 我有很多功能需要连续运行,但不能在另一个功能完成之前运行.我需要的是一种方法,将这些函数排队,只有在上一个函数成功完成后才能运行.有任何想法吗?
Function1();
Function2();
Function3();
Function4();
Function5();
Run Code Online (Sandbox Code Playgroud)