If date formatting sucks in JavaScript, number formatting is just as worst. Like moment.js, numeral.js is a library that fills this JavaScript gaping hole.

I was waiting that someone would come up and ask me why do I format in JavaScript (front end) instead in the backend. Well, my reason is threefold. First and foremost, dates and numbers are typically manipulated on the front end (sorting, arithmetic operation, etc.). Any formatting done in the backend will be lost once the data is updated on the front end.

Second, it offloads any trivial formatting to the client’s browser and save you precious server resources.

Lastly, it moves formatting to the view layer where it rightfully belongs.