-
-
Save icesernia/52286b2de088dda9033ac55c4743d2e4 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 number = 123456.789; | |
console.log(new Intl.NumberFormat('th').format(number)); // expected output: 123,456.789 | |
console.log(new Intl.NumberFormat('en-US', {style: 'unit', unit: 'liter'}).format(number)); // expected output: 123,456.789 L | |
console.log(new Intl.NumberFormat('en-GB', {style: 'unit', unit: 'liter'}).format(number)); // expected output: 123,456.789 l | |
console.log(new Intl.NumberFormat('en-US', {style: 'unit', unit: 'byte'}).format(number)); // expected output: 123,456.789 byte | |
console.log(new Intl.NumberFormat('en-US', { notation: "scientific" }).format(number)); // expected output: 1.235E5 | |
console.log(new Intl.NumberFormat('en-US', { style: 'currency', currency: 'THB' }).format(number));// expected output: THB 123,456.79 | |
console.log(new Intl.NumberFormat('th', { style: 'currency', currency: 'THB' }).format(number)); // expected output: ฿123,456.79 | |
console.log(new Intl.NumberFormat('th-TH-u-nu-thai', { style: 'currency', currency: 'THB' }).format(number)); // expected output: ฿๑๒๓,๔๕๖.๗๙ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment