How to add formatting to javascript's number display globally
<p>In Javascript I have a number and I want to add comma to it when it's displayed as a string.</p>

<p>I can add comma to the number like this:</p>

<pre>
function numberWithCommas(value) {
  return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

</pre>

<p>But I don't want to call a method on every number that we have to get this.  I want to do something similar to this:</p>

<pre>
Number.prototype.toString = function(radix) {
  return numberWithCommas(this);
}
</pre>

<p>So when I do the following, the right value will show up:</p>

<pre>

var num = 100000;
alert(num); // 100,000
</pre>

<p>Can't get the above to work.  Any ideas?</p>
