r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

43

u/jesusthatsgreat May 28 '19

Formatting dates. You don't need a bulky third party library. toLocaleDateString() will do the job in 99% of cases.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString

5

u/Bosmonster May 28 '19

For Node you will need to add Localization for it to work properly, so that might be a reason, especially if you don't have control over the environment.

Also the options for dateString are fairly limited compared to some of the libraries out there. For example relative date/time.