Javascript Number formatString(num, comma)
/* Extended JavaScript Number library * Copyright 2009 Jaakko-Heikki Heusala <jheusala@iki.fi> * $Id: $/* w w w. j a v a2s .c o m*/ */ /* Format number */ Number.prototype.formatString = function(num, comma) { return this.toFixed(num).toString().replace(/\.([0-9]*)$/, comma+"$1"); }