Created
January 29, 2017 07:36
-
-
Save davidgilbertson/963c3bcc9f6d96554b7aa6a96525dd8c 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
const price = 1234.567; | |
const formattedPrice = price.toLocaleString('en', { | |
style: 'currency', | |
currency: 'USD' | |
}); | |
console.log(formattedPrice); // "$1,234.57" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately not widely supported, yet: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#Browser_compatibility