Mehul Lakhanpal
Posted on • Originally published atcodedrops.tech
Pretty format number using '.toLocaleString()'
// Errorconsole.log(123456.toLocaleString());// wont work// Method 1: Store it in a variableconstn=123456;console.log(n.toLocaleString());// 123,456// Method 2: Use Number() to convert it into type Numberconsole.log(Number(12345).toLocaleString());// 12,345
Thanks for reading 💙
Follow@codedrops.tech for more.
Instagram ●Twitter ●Facebook
Micro-Learning ● Web Development ● Javascript ● MERN stack
codedrops.tech
Projects
File Ops - A VS Code extension to easily tag/alias files & quick switch between files
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse