Skip to content

Instantly share code, notes, and snippets.

@Go7hic
Last active February 9, 2017 16:41
Show Gist options
  • Save Go7hic/4ada8ac1de8da41faebccfe418eabfc5 to your computer and use it in GitHub Desktop.
Save Go7hic/4ada8ac1de8da41faebccfe418eabfc5 to your computer and use it in GitHub Desktop.
JS 工具函数集 #tags:jsutils
// 千位数
function commafy(num) {
num = num + '';
var reg = /(-?\d+)(\d{3})/;
while(reg.test(num)) {
num = num.replace(reg, '$1,$2');
}
return num;
}
// isNumber
const isNumber = x => Number(x) === x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment