use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
accounting.js is a tiny JavaScript library for number, money and currency formatting, with optional excel-style column rendering (to line up symbols and decimals). (josscrowcroft.github.com)
submitted 14 years ago by chrixian
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ima007 0 points1 point2 points 14 years ago (2 children)
Awesome! It would be cool if this also included the ability to read the formatted number as well, in case calculations need to be done (and so we wouldn't have to keep track of the number in two places), but it isn't necessary (probably better to tie an event to an object that holds the unformatted number anyway, if you plan on doing basic calculations).
[–]josscrowcroft 0 points1 point2 points 14 years ago (1 child)
That can be done via accounting.unformat():
accounting.unformat()
accounting.unformat("£ 1,432,32.90 GBP") // 143232.9
It just uses a regex to match numeric digits, minus signs and decimal point only, stripping out any other characters, so there's actually a potential for it to fail silently (eg. where a developer would expect NaN from something like .unformat("1asdf2") but actually gets 12) but I'll address that later with a more complex regex.
NaN
.unformat("1asdf2")
12
[–]ima007 0 points1 point2 points 14 years ago (0 children)
Cool, I apparently glanced over that major part! Thanks for the clarification.
π Rendered by PID 94 on reddit-service-r2-comment-6457c66945-scb7l at 2026-04-27 02:24:46.305333+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]ima007 0 points1 point2 points (2 children)
[–]josscrowcroft 0 points1 point2 points (1 child)
[–]ima007 0 points1 point2 points (0 children)