title: Javascript: Easier way to format numbers?
body: <p>I'm trying to format various numbers on my page.  These numbers either represent a price, a change in price, or a percentage.  I know Javascript has functions to limit the number of decimal places, but is there any support for other types of formatting, such as grouping numbers with commas, controlling whether or not the +/- is shown, etc?  Here's what I have so far:</p>
  
  <pre><code>var FORMATTER = {
      price       : function(value) { return '$' + value.toFixed(2); },
      pricePer    : function(value) { return (value * 100).toFixed(2) + '%'; },
      priceChg    : function(value) { return (value &gt;= 0 ? '+' : '-') + '$' + Math.abs(value).toFixed(2); }
  };
  </code></pre>
  
  <p>It works OK, but it'd like to add commas to the 'price' formatter, and you can see that there's a hack in the 'priceChg' formatter where I try to move the +/- sign in front of the '$' sign.</p>
  
  <p>Basically, I'm hoping there is some library out there (jQuery is OK) that emulates Java's DecimalFormat class.</p>