JavaScript has a new(ish) Intl API. You may be thinking “Internationalization? I only have users in the US, why would I use this?“. You fool, take a look. Here’s what it can do.
Format Dates: Similar to the toLocaleDateString method on the Date object, you can use this to format Dates, but with Intl you get some extra options like timeZone.
Format Numbers: You can also use Intl to format Numbers.
Format Lists: As Oxford comma maximalists, we appreciate that it can render lists properly too.
Text Segmentation:
The last feature we’ll highlight (there are more) is language specific text segmentation. Doing a str.split(”) on non-english strings is a good way to introduce bugs.