.toLocaleString and friends are some of the most underrated features of JavaScript. I came over them through a few different wanderings through MDN...
For further actions, you may consider blocking this person and/or reporting abuse
Not only in JS, there are bugs in some games due to forgetting about this when dealing with dates in C# in Unity and so on π
Haha, dates are a pain
Blain is a Pain
No Pain no Blain πͺπΌπ
I have used it for dates before, but really didnβt realize that I can do all of this βΊοΈ
Great Article! ππ»ππ»
My mind is blown, I've used it a ton of times for date formatting but didn't even know it had some more properties for dates! And that it can also be used for numbers π€―.
I'm definitely trying this out.
Thanks for this piece.
Didn't even realise you can do all this, thank you for the sharing
good one ..
awesome, why the .. for some items and not others?
In JavaScript, you can't directly access properties on numbers. You can either use 2 dots or braces instead
I'm using this feature a lot when displaying dates !
Thank you.
Good post and useful feature π
Thanks!
Thanks for sharing π
Nice π
I didn't know about that - WOW! this is awesome :) thank u very much for this article!
MIND BLOWN! Iβll use it for sure!! Thanks!!
I used it for dates only but very basic only. Didn't know all this was possible.
Thanks Siddharth!!
Thanks, that helped a lot!!
Goodbye libraries for number formatting! =D
clear explanation ! :)
Exactly what I need at the moment. Thank you so much.
Was that pun intended π€£
What are the differences between
Number#toString()
andIntl.NumberFormat
?.toString
doesn't provide the features ofIntl
. It only supports stringifying to a base.Sorry, I meant
.toLocaleString()
The features are the same, except
Intl
is faster when you need to run the stringification multiple timesAh, thanks!