Created
September 24, 2024 13:27
-
-
Save ValchanOficial/6dc1cd4203101d38b3c93f865313c92e to your computer and use it in GitHub Desktop.
[Javascript][NumberFormat][toLocaleString][currency]
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
// Info: \u00a0 é o que é o espaço sem quebra | |
const number = 123456.789; | |
console.log(new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(number).replace(/\u00a0/g, ' ')); | |
console.log(Number(number).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' }).replace(/\u00a0/g, ' ')) | |
// Output: "R$ 123.456,79" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment