Converting a number to currency with Javascript

I recently needed a way to convert a number to currency format using Javascript.  I found the best solution in Alex G’s comment on Brad Harris’s post.  But as usual, there were issues when cutting/pasting from the web so I just wanted to post here as a Gist so it might help someone else and also so that someone can improve it if they want.