Last active
December 21, 2016 15:46
-
-
Save gracefullight/d39f2407c7ce5d8b6dc01e6a6992aebd to your computer and use it in GitHub Desktop.
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 | |
function comma(num){ | |
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
} | |
// prototype | |
Number.prototype.format = function(){ | |
return this.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment