Created
November 11, 2016 09:24
-
-
Save zdying/e27780ebd769d02ee23e05f2413a0c2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript | |
function numberWithCommas(x) { | |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
} | |
// or use Nuber.prototype.toLocaleString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment