Last active
February 9, 2017 16:41
-
-
Save Go7hic/4ada8ac1de8da41faebccfe418eabfc5 to your computer and use it in GitHub Desktop.
JS 工具函数集 #tags:jsutils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 千位数 | |
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