Formatting currency in JavaScript

Updated

I’ve been hunting for something like Rails’ number_to_currency for Javascript that’d give me a delimited output with precision in cents.

Most of what I found didn’t work well so I rolled my own. The code is fairly simple compared to other alternatives and can be easily modified to work with other currencies or dollar amounts.

Usage

CoffeeScript Implementation

Javascript Implementation

blog comments powered by Disqus